From: Rob Landley Date: Thu, 1 Sep 2005 10:23:57 +0000 (-0000) Subject: According to bug #63, crond is unhappy with crontab lines that don't end in a X-Git-Tag: 1_1_0~793 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=828548ab56ed2dca36daf0dfdbb0644119ecbe2c;p=oweals%2Fbusybox.git According to bug #63, crond is unhappy with crontab lines that don't end in a newline, or lines that have trailing spaces. --- diff --git a/libbb/trim.c b/libbb/trim.c index 38aa28231..0dca6678e 100644 --- a/libbb/trim.c +++ b/libbb/trim.c @@ -29,14 +29,18 @@ void trim(char *s) { - int len = strlen(s); + size_t len = strlen(s); + size_t lws; /* trim trailing whitespace */ - while ( len > 0 && isspace(s[len-1])) - s[--len]='\0'; + while (len && isspace(s[len-1])) --len; /* trim leading whitespace */ - memmove(s, &s[strspn(s, " \n\r\t\v")], len); + if(len) { + lws = strspn(s, " \n\r\t\v"); + memmove(s, s + lws, len -= lws); + } + s[len] = 0; } /* END CODE */ diff --git a/miscutils/crond.c b/miscutils/crond.c index 085cf6e9d..53c255fef 100644 --- a/miscutils/crond.c +++ b/miscutils/crond.c @@ -589,10 +589,8 @@ static void SynchronizeFile(const char *fileName) CronLine line; char *ptr; - if (buf[0]) { - buf[strlen(buf) - 1] = 0; - } - if (buf[0] == 0 || buf[0] == '#' || buf[0] == ' ' || buf[0] == '\t') { + trim(buf); + if (buf[0] == 0 || buf[0] == '#') { continue; } if (--maxEntries == 0) {