Fix potential buffer overflow by using dynamic buffer size.
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 27 Aug 2007 06:48:00 +0000 (09:48 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 27 Aug 2007 06:48:00 +0000 (09:48 +0300)
rpmio/macro.c

index 52a7bc5..3c2070d 100644 (file)
@@ -1080,7 +1080,10 @@ doOutput(MacroBuf mb, int waserror, const char * msg, size_t msglen)
        /*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
        /*@modifies mb, rpmGlobalMacroContext, fileSystem @*/
 {
-    char buf[BUFSIZ];
+    char *buf;
+
+    buf = alloca(msglen + 1);
+    memset(buf, 0, (msglen + 1));
 
     strncpy(buf, msg, msglen);
     buf[msglen] = '\0';