Fix parsing of '0' and non-alphanumerics in steps. Previously, an

entry having stepping value of zero can cause crontab to hang there,
and if the main crontab is being changed in this way, then cron(8)
will keep spining.

Obtained from:	OpenBSD [src/usr.sbin/cron/entry.c,v 1.17]
PR:		68683 (my own, but forgot to commit it...)
MFC After:	1 week
This commit is contained in:
Xin LI 2005-02-14 14:09:21 +00:00
parent 843cfd5ae0
commit d159401da0

View File

@ -543,7 +543,7 @@ get_range(bits, low, high, names, ch, file)
* sent as a 0 since there is no offset either. * sent as a 0 since there is no offset either.
*/ */
ch = get_number(&num3, 0, PPC_NULL, ch, file); ch = get_number(&num3, 0, PPC_NULL, ch, file);
if (ch == EOF) if (ch == EOF || num3 == 0)
return EOF; return EOF;
} else { } else {
/* no step. default==1. /* no step. default==1.
@ -592,6 +592,8 @@ get_number(numptr, low, names, ch, file)
ch = get_char(file); ch = get_char(file);
} }
*pc = '\0'; *pc = '\0';
if (len == 0)
return (EOF);
/* try to find the name in the name list /* try to find the name in the name list
*/ */