Cron dies - why! (Bug fix.)
Sven Wiberg
wiberg at chalmers.UUCP
Fri Jan 27 00:43:46 AEST 1984
(Blank line)
It seems like some people out there have been bitten by the same
bug as we, so here's a diff list of our fix. It has worked as far
as we can see, which is only about a week.
1a2,17
>
> /*
> * cron.c - clock daemon.
> *
> * Chalmers bug fix, 1984 01 23:
> * Test for list space (100 bytes ahead) in main loop of init()
> * was insufficient for long lines at certain places in crontab,
> * causing segmentation faults. It has been moved into each
> * nested loop and now has to think just a few bytes ahead at a
> * time, thus permitting arbitrarily long lines anywhere.
> * Also, an error test on the initial fork() has been added,
> * and harmless but redundant calls to free() before realloc()
> * have been removed.
> * CB & STW.
> */
>
10d25
<
15a31
>
27a44
> register int fret;
32,33c49,55
< /* setuid(1); */
< if (fork())
---
> /* setuid(1); */
> if ((fret=fork()) < 0) /* CB - 84 01 19 */
> {
> fprintf(stderr,"Cron: can't fork\n");
> exit(1);
> }
> else if(fret)
140,143c162,163
< register i, c;
< register char *cp;
< register char *ocp;
< register int n;
---
> register i, c, n;
> register char *cp, *ocp, *olist;
146,147c166
< if (list) {
< free(list);
---
> if (list)
149c168
< } else
---
> else
154,162c173
< loop:
< if(cp > list+listsize-100) {
< char *olist;
< listsize += LISTS;
< olist = list;
< free(list);
< list = realloc(list, listsize);
< cp = list + (cp - olist);
< }
---
> loop: /* List space test moved. STW - 84 01 23 */
172a184,188
> if(cp >= list+listsize-3) { /* STW - 84 01 23 */
> olist = list;
> list = realloc(list, listsize += LISTS);
> cp = list + (cp - olist);
> }
195a212,216
> if(cp >= list+listsize-2) { /* STW - 84 01 23 */
> olist = list;
> list = realloc(list, listsize += LISTS);
> cp = list + (cp - olist);
> }
218a240,244
> if(cp >= list+listsize-3) { /* STW - 84 01 23 */
> olist = list;
> list = realloc(list, listsize += LISTS);
> cp = list + (cp - olist);
> }
229a256,260
> if(cp >= list+listsize-2) { /* STW - 84 01 23 */
> olist = list;
> list = realloc(list, listsize += LISTS);
> cp = list + (cp - olist);
> }
Good luck!
Sven T. Wiberg @ Chalmers
More information about the Comp.unix.wizards
mailing list