diff options
| author | Rob Landley <rob@landley.net> | 2005-09-01 10:23:57 +0000 |
|---|---|---|
| committer | Rob Landley <rob@landley.net> | 2005-09-01 10:23:57 +0000 |
| commit | 828548ab56ed2dca36daf0dfdbb0644119ecbe2c (patch) | |
| tree | ef98f8bb5478276a0a5cb15d127ae79fba8f1dea | |
| parent | 344ea471ef63d54436f296c140e7f86c67237545 (diff) | |
| download | busybox-w32-828548ab56ed2dca36daf0dfdbb0644119ecbe2c.tar.gz busybox-w32-828548ab56ed2dca36daf0dfdbb0644119ecbe2c.tar.bz2 busybox-w32-828548ab56ed2dca36daf0dfdbb0644119ecbe2c.zip | |
According to bug #63, crond is unhappy with crontab lines that don't end in a
newline, or lines that have trailing spaces.
| -rw-r--r-- | libbb/trim.c | 12 | ||||
| -rw-r--r-- | miscutils/crond.c | 6 |
2 files changed, 10 insertions, 8 deletions
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 @@ | |||
| 29 | 29 | ||
| 30 | void trim(char *s) | 30 | void trim(char *s) |
| 31 | { | 31 | { |
| 32 | int len = strlen(s); | 32 | size_t len = strlen(s); |
| 33 | size_t lws; | ||
| 33 | 34 | ||
| 34 | /* trim trailing whitespace */ | 35 | /* trim trailing whitespace */ |
| 35 | while ( len > 0 && isspace(s[len-1])) | 36 | while (len && isspace(s[len-1])) --len; |
| 36 | s[--len]='\0'; | ||
| 37 | 37 | ||
| 38 | /* trim leading whitespace */ | 38 | /* trim leading whitespace */ |
| 39 | memmove(s, &s[strspn(s, " \n\r\t\v")], len); | 39 | if(len) { |
| 40 | lws = strspn(s, " \n\r\t\v"); | ||
| 41 | memmove(s, s + lws, len -= lws); | ||
| 42 | } | ||
| 43 | s[len] = 0; | ||
| 40 | } | 44 | } |
| 41 | 45 | ||
| 42 | /* END CODE */ | 46 | /* 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) | |||
| 589 | CronLine line; | 589 | CronLine line; |
| 590 | char *ptr; | 590 | char *ptr; |
| 591 | 591 | ||
| 592 | if (buf[0]) { | 592 | trim(buf); |
| 593 | buf[strlen(buf) - 1] = 0; | 593 | if (buf[0] == 0 || buf[0] == '#') { |
| 594 | } | ||
| 595 | if (buf[0] == 0 || buf[0] == '#' || buf[0] == ' ' || buf[0] == '\t') { | ||
| 596 | continue; | 594 | continue; |
| 597 | } | 595 | } |
| 598 | if (--maxEntries == 0) { | 596 | if (--maxEntries == 0) { |
