Potential fix for code scanning alert no. 55: Call to alloca in a loop (#175)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
Thomas Arp
2026-04-21 23:20:23 +02:00
committed by GitHub
parent d4089c58e8
commit 10251814f6

View File

@@ -2102,9 +2102,11 @@ static void ExecuteMSDPPair( descriptor_t *apDescriptor, const char *apVariable,
!strcmp(apDescriptor->pProtocol->pVariables[i]->pValueString, "Unknown") )
{
/* Store the new value if it's valid */
char *pBuffer = alloca(VariableNameTable[i].Max+1);
char *pBuffer = malloc(VariableNameTable[i].Max + 1);
int j; /* Loop counter */
if ( pBuffer != NULL )
{
for ( j = 0; j < VariableNameTable[i].Max && *apValue != '\0'; ++apValue )
{
if ( isprint(*apValue) )
@@ -2117,6 +2119,9 @@ static void ExecuteMSDPPair( descriptor_t *apDescriptor, const char *apVariable,
free(apDescriptor->pProtocol->pVariables[i]->pValueString);
apDescriptor->pProtocol->pVariables[i]->pValueString = AllocString(pBuffer);
}
free(pBuffer);
}
}
}
else /* This variable only accepts numeric values */