[BusyBox] PATCH for crond EOL bug
Pauli Saksa
psaksa at cc.hut.fi
Wed Jul 20 04:16:50 MDT 2005
> So, ignore the previous patch, more complete patch attached.
Once more with feeling... and without encoding with hopes that the patch
is actually read and applied some day.
--
Pauli Saksa
psaksa at cc.hut.fi
-------------- next part --------------
Index: libbb/trim.c
===================================================================
--- libbb/trim.c (revision 10869)
+++ libbb/trim.c (working copy)
@@ -29,14 +29,20 @@
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';
+ --len;
/* trim leading whitespace */
- memmove(s, &s[strspn(s, " \n\r\t\v")], len);
+ if(len > 0) {
+ lws = strspn(s, " \n\r\t\v");
+ len -= lws;
+ memmove(s, s + lws, len);
+ }
+ s[len] = 0;
}
/* END CODE */
Index: miscutils/crond.c
===================================================================
--- miscutils/crond.c (revision 10869)
+++ miscutils/crond.c (working copy)
@@ -132,7 +132,7 @@
if (LogFile == 0) {
vsyslog(type, fmt, va);
} else {
- int logfd = open(LogFile, O_WRONLY | O_CREAT | O_APPEND, 600);
+ int logfd = open(LogFile, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
if (logfd >= 0) {
vdprintf(logfd, fmt, va);
close(logfd);
@@ -589,10 +589,8 @@
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) {
More information about the busybox
mailing list