Fix potential buffer overflow in macro primitive execution

Use dynamic buffer, we know the needed size here...
This commit is contained in:
Panu Matilainen 2007-08-27 09:55:42 +03:00
parent ad7c8e98c9
commit 40d25ee3ea
1 changed files with 3 additions and 2 deletions

View File

@ -1111,10 +1111,11 @@ doFoo(MacroBuf mb, int negate, const char * f, size_t fn,
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies mb, rpmGlobalMacroContext, fileSystem, internalState @*/
{
char buf[BUFSIZ], *b = NULL, *be;
char *buf, *b = NULL, *be;
int c;
buf[0] = '\0';
buf = alloca(gn + 1);
memset(buf, 0, gn + 1);
if (g != NULL) {
strncpy(buf, g, gn);
buf[gn] = '\0';