fix botch that causes sendmail to core dump when there are large
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 5 Jan 1983 02:58:55 +0000 (18:58 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 5 Jan 1983 02:58:55 +0000 (18:58 -0800)
numbers of requests

SCCS-mr: usr.sbin/sendmail/src/version.c 133
SCCS-vsn: usr.sbin/sendmail/src/queue.c 3.66
SCCS-vsn: usr.sbin/sendmail/src/version.c 3.279

usr/src/usr.sbin/sendmail/src/queue.c
usr/src/usr.sbin/sendmail/src/version.c

index 00d5347..8b8ebe5 100644 (file)
@@ -5,10 +5,10 @@
 # include <errno.h>
 
 # ifndef QUEUE
 # include <errno.h>
 
 # ifndef QUEUE
-SCCSID(@(#)queue.c     3.65            %G%     (no queueing));
+SCCSID(@(#)queue.c     3.66            %G%     (no queueing));
 # else QUEUE
 
 # else QUEUE
 
-SCCSID(@(#)queue.c     3.65            %G%);
+SCCSID(@(#)queue.c     3.66            %G%);
 
 /*
 **  Work queue.
 
 /*
 **  Work queue.
@@ -263,7 +263,8 @@ runqueue(forkflag)
 **             none.
 **
 **     Returns:
 **             none.
 **
 **     Returns:
-**             none.
+**             The number of request in the queue (not necessarily
+**             the number of requests in WorkQ however).
 **
 **     Side Effects:
 **             Sets WorkQ to the queue of available work, in order.
 **
 **     Side Effects:
 **             Sets WorkQ to the queue of available work, in order.
@@ -287,7 +288,7 @@ orderq()
        register WORK **wp;             /* parent of w */
        DIR *f;
        register int i;
        register WORK **wp;             /* parent of w */
        DIR *f;
        register int i;
-       WORK wlist[WLSIZE];
+       WORK wlist[WLSIZE+1];
        int wn = -1;
        extern workcmpf();
 
        int wn = -1;
        extern workcmpf();
 
@@ -366,7 +367,7 @@ orderq()
        **  Sort the work directory.
        */
 
        **  Sort the work directory.
        */
 
-       qsort(wlist, wn, sizeof *wlist, workcmpf);
+       qsort(wlist, min(wn, WLSIZE), sizeof *wlist, workcmpf);
 
        /*
        **  Convert the work list into canonical form.
 
        /*
        **  Convert the work list into canonical form.
@@ -374,7 +375,7 @@ orderq()
        */
 
        wp = &WorkQ;
        */
 
        wp = &WorkQ;
-       for (i = 0; i < wn; i++)
+       for (i = min(wn, WLSIZE); --i >= 0; )
        {
                w = (WORK *) xalloc(sizeof *w);
                w->w_name = wlist[i].w_name;
        {
                w = (WORK *) xalloc(sizeof *w);
                w->w_name = wlist[i].w_name;
@@ -402,16 +403,14 @@ orderq()
 **             b -- the second argument.
 **
 **     Returns:
 **             b -- the second argument.
 **
 **     Returns:
-**             -1 if a < b
+**             1 if a < b
 **             0 if a == b
 **             0 if a == b
-**             1 if a > b
+**             -1 if a > b
 **
 **     Side Effects:
 **             none.
 */
 
 **
 **     Side Effects:
 **             none.
 */
 
-# define PRIFACT       1800            /* bytes each priority point is worth */
-
 workcmpf(a, b)
        register WORK *a;
        register WORK *b;
 workcmpf(a, b)
        register WORK *a;
        register WORK *b;
@@ -419,9 +418,9 @@ workcmpf(a, b)
        if (a->w_pri == b->w_pri)
                return (0);
        else if (a->w_pri > b->w_pri)
        if (a->w_pri == b->w_pri)
                return (0);
        else if (a->w_pri > b->w_pri)
-               return (1);
-       else
                return (-1);
                return (-1);
+       else
+               return (1);
 }
 \f/*
 **  DOWORK -- do a work request.
 }
 \f/*
 **  DOWORK -- do a work request.
index 542c1f3..3ec5131 100644 (file)
@@ -1,5 +1,5 @@
 # ifndef lint
 # ifndef lint
-static char    SccsId[] = "@(#)SendMail version 3.278 of %G%";
+static char    SccsId[] = "@(#)SendMail version 3.279 of %G%";
 # endif lint
 
 # endif lint
 
-char   Version[] = "3.278 [%G%]";
+char   Version[] = "3.279 [%G%]";