Fixed time parsing in shutdown when there is a + in front of a 0 time offset.

Commands with a postiive time offset (+1) would work but +0 fails.
This has been corrected by Arkadiusz Miskiewicz.
This commit is contained in:
Jesse Smith 2020-08-15 18:50:58 -03:00
parent 7ca2d2413f
commit 462a92ce2a

View File

@ -777,16 +777,18 @@ int main(int argc, char **argv)
if (!strcmp(when, "now")) strcpy(when, "0");
sp = when;
if (when[0] == '+') sp++;
/* Decode shutdown time. */
/* Validate time argument. */
for ( ; *sp; sp++) {
if (*sp != ':' && (*sp < '0' || *sp > '9'))
if (*sp != '+' && *sp != ':' && (*sp < '0' || *sp > '9'))
usage();
}
sp = when;
/* Decode shutdown time. */
if (when[0] == '+') sp++;
if (strchr(when, ':') == NULL) {
/* Time in minutes. */
wt = atoi(when);
if (wt == 0 && when[0] != '0') usage();
wt = atoi(sp);
if (wt == 0 && sp[0] != '0') usage();
} else {
if (sscanf(when, "%d:%2d", &hours, &mins) != 2) usage();
/* Time in hh:mm format. */