]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - scripts/mod/modpost.c
[PATCH] kbuild: fix buffer overflow in modpost
[linux-2.6-omap-h63xx.git] / scripts / mod / modpost.c
index f70ff13d481834b14ceb926879a6a3a2e99e1894..b8b2a560b26bdec79376abe7785c14abbbba8ffd 100644 (file)
@@ -508,12 +508,7 @@ buf_printf(struct buffer *buf, const char *fmt, ...)
        
        va_start(ap, fmt);
        len = vsnprintf(tmp, SZ, fmt, ap);
-       if (buf->size - buf->pos < len + 1) {
-               buf->size += 128;
-               buf->p = realloc(buf->p, buf->size);
-       }
-       strncpy(buf->p + buf->pos, tmp, len + 1);
-       buf->pos += len;
+       buf_write(buf, tmp, len);
        va_end(ap);
 }
 
@@ -521,7 +516,7 @@ void
 buf_write(struct buffer *buf, const char *s, int len)
 {
        if (buf->size - buf->pos < len) {
-               buf->size += len;
+               buf->size += len + SZ;
                buf->p = realloc(buf->p, buf->size);
        }
        strncpy(buf->p + buf->pos, s, len);