diff options
Diffstat (limited to 'usr/src/cmd/cron/crontab.c')
-rw-r--r-- | usr/src/cmd/cron/crontab.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/usr/src/cmd/cron/crontab.c b/usr/src/cmd/cron/crontab.c index d85c9c554b..4ff985240e 100644 --- a/usr/src/cmd/cron/crontab.c +++ b/usr/src/cmd/cron/crontab.c @@ -27,6 +27,7 @@ /* * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2022 Sebastian Wiedenroth */ #include <sys/types.h> @@ -96,6 +97,7 @@ #define BAD_TZ "Timezone unrecognized in: %s" #define BAD_SHELL "Invalid shell specified: %s" #define BAD_HOME "Unable to access directory: %s\t%s\n" +#define BAD_RAND_DELAY "Invalid delay: %s" extern int per_errno; @@ -428,6 +430,7 @@ copycron(FILE *fp) char pid[6], *tnam_end; int t; char buf[LINE_MAX]; + const char *errstr; cferror_t cferr; sprintf(pid, "%-5d", getpid()); @@ -460,7 +463,7 @@ copycron(FILE *fp) if (strncmp(&line[cursor], ENV_TZ, strlen(ENV_TZ)) == 0) { char *x; - strncpy(buf, &line[cursor + strlen(ENV_TZ)], + (void) strncpy(buf, &line[cursor + strlen(ENV_TZ)], sizeof (buf)); if ((x = strchr(buf, '\n')) != NULL) *x = '\0'; @@ -476,7 +479,7 @@ copycron(FILE *fp) strlen(ENV_SHELL)) == 0) { char *x; - strncpy(buf, &line[cursor + strlen(ENV_SHELL)], + (void) strncpy(buf, &line[cursor + strlen(ENV_SHELL)], sizeof (buf)); if ((x = strchr(buf, '\n')) != NULL) *x = '\0'; @@ -492,7 +495,7 @@ copycron(FILE *fp) strlen(ENV_HOME)) == 0) { char *x; - strncpy(buf, &line[cursor + strlen(ENV_HOME)], + (void) strncpy(buf, &line[cursor + strlen(ENV_HOME)], sizeof (buf)); if ((x = strchr(buf, '\n')) != NULL) *x = '\0'; @@ -504,6 +507,25 @@ copycron(FILE *fp) strerror(errno)); continue; } + } else if (strncmp(&line[cursor], ENV_RANDOM_DELAY, + strlen(ENV_RANDOM_DELAY)) == 0) { + char *x; + + (void) strncpy(buf, + &line[cursor + strlen(ENV_RANDOM_DELAY)], + sizeof (buf)); + if ((x = strchr(buf, '\n')) != NULL) + *x = '\0'; + + (void) strtonum(buf, 0, UINT32_MAX / 60, &errstr); + if (errstr == NULL) { + goto cont; + } else { + err = 1; + fprintf(stderr, BAD_RAND_DELAY, + &line[cursor], strerror(errno)); + continue; + } } if ((cferr = next_field(0, 59, line, &cursor, NULL)) != CFOK || |