]> diplodocus.org Git - nmh/commitdiff
Don't let scan() use too large a width (BUFSIZ for now) to prevent
authorDavid Levine <levinedl@acm.org>
Tue, 2 Sep 2014 01:14:52 +0000 (20:14 -0500)
committerDavid Levine <levinedl@acm.org>
Tue, 2 Sep 2014 01:14:52 +0000 (20:14 -0500)
allocating a huge output buffer.

uip/scansbr.c

index 2111bc16e126afbed3811595d3791be1a4b3f01d..3c6b771d3bb719ab6a500e7f25a93e0793ab57ad 100644 (file)
@@ -134,7 +134,7 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
        if (used_buf == NULL)
            adios (NULL, "unable to allocate component buffer stack");
        used_buf += ncomps+1; *--used_buf = 0;
-       rlwidth = bodycomp && (width > SBUFSIZ) ? width : SBUFSIZ;
+       rlwidth = bodycomp && (width > SBUFSIZ) ? min (width, BUFSIZ) : SBUFSIZ;
        for (i = ncomps; i--; )
            *nxtbuf++ = mh_xmalloc(rlwidth);
     }