]> diplodocus.org Git - nmh/commitdiff
Fixed commit 2adafe760a9c45b417727a3f5d9481de26471a8b to not
authorDavid Levine <levinedl@acm.org>
Sun, 5 Oct 2014 03:43:21 +0000 (22:43 -0500)
committerDavid Levine <levinedl@acm.org>
Sun, 5 Oct 2014 03:43:21 +0000 (22:43 -0500)
try to allocate a charstring_t of length INT_MAX with -width 0.

uip/ap.c
uip/dp.c
uip/scansbr.c

index 3dd77b171a56bc1b930db8ce54f884df0d193b85..b231a0ebef8c4249c560fb75223b656ba9932952 100644 (file)
--- a/uip/ap.c
+++ b/uip/ap.c
@@ -112,11 +112,11 @@ main (int argc, char **argv)
        if ((width = sc_width ()) < WIDTH / 2) {
            /* Default:  width of the terminal, but at least WIDTH/2. */
            width = WIDTH / 2;
-       } else if (width == 0) {
-           /* Unlimited width. */
-           width = INT_MAX;
        }
        width -= 2;
+    } else if (width == 0) {
+       /* Unlimited width.  */
+       width = INT_MAX;
     }
     fmt_compile (nfs, &fmt, 1);
 
@@ -169,19 +169,20 @@ process (char *arg, int length)
     }
 
     for (p = pq.pq_next; p; p = q) {
-       charstring_t scanl = charstring_create (length);
+       charstring_t scanl =
+           charstring_create (length < NMH_BUFSIZ ? length : NMH_BUFSIZ);
 
        cptr = fmt_findcomp ("text");
        if (cptr) {
            if (cptr->c_text)
-               free(cptr->c_text);
+               free(cptr->c_text);
            cptr->c_text = p->pq_text;
            p->pq_text = NULL;
        }
        cptr = fmt_findcomp ("error");
        if (cptr) {
            if (cptr->c_text)
-               free(cptr->c_text);
+               free(cptr->c_text);
            cptr->c_text = p->pq_error;
            p->pq_error = NULL;
        }
index 2e07197303ad4ef3f30d1f35cf3a63c6cb502346..cf8f9b1406210809429d5bc875ded7ab31d59ed1 100644 (file)
--- a/uip/dp.c
+++ b/uip/dp.c
@@ -108,11 +108,11 @@ main (int argc, char **argv)
        if ((width = sc_width ()) < WIDTH / 2) {
            /* Default:  width of the terminal, but at least WIDTH/2. */
            width = WIDTH / 2;
-       } else if (width == 0) {
-           /* Unlimited width. */
-           width = INT_MAX;
        }
        width -= 2;
+    } else if (width == 0) {
+       /* Unlimited width.  */
+       width = INT_MAX;
     }
     fmt_compile (nfs, &fmt, 1);
 
@@ -136,7 +136,8 @@ static int
 process (char *date, int length)
 {
     int status = 0;
-    charstring_t scanl = charstring_create (length);
+    charstring_t scanl =
+       charstring_create (length < NMH_BUFSIZ ? length : NMH_BUFSIZ);
     register struct comp *cptr;
 
     cptr = fmt_findcomp ("text");
index 749743c1c4c3f55b2461ccc3e74f2f8c834fef8f..afc090115a482bdd6553dd3ce47af3f157397b00 100644 (file)
@@ -75,7 +75,7 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
            width = INT_MAX;
        }
        dat[3] = slwidth = width;
-       *scanl = charstring_create (width);
+       *scanl = charstring_create (width < NMH_BUFSIZ ? width : NMH_BUFSIZ);
        if (outnum)
            umask(~m_gmprot());