diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-07-17 11:59:13 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-07-17 11:59:13 +0000 |
commit | 679212836a881b53382ea6bd811f38e00705d50d (patch) | |
tree | e5c349683a57c55b650eae77b1ca5ac40c94a175 /miscutils/crond.c | |
parent | 0f683f818cf087d580ba2edf7c096897bc28b95a (diff) | |
download | busybox-w32-679212836a881b53382ea6bd811f38e00705d50d.tar.gz busybox-w32-679212836a881b53382ea6bd811f38e00705d50d.tar.bz2 busybox-w32-679212836a881b53382ea6bd811f38e00705d50d.zip |
- fix segfault in nameif with mactab file
(by fixing and shrink config parser)
function old new delta
config_free_data - 37 +37
config_open 43 48 +5
pack_gzip 1658 1660 +2
nameif_main 527 525 -2
SynchronizeFile 629 623 -6
make_device 1184 1176 -8
config_close 31 18 -13
config_read 431 393 -38
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/5 up/down: 44/-67) Total: -23 bytes
Diffstat (limited to 'miscutils/crond.c')
-rw-r--r-- | miscutils/crond.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c index 41f151753..d8423cf4f 100644 --- a/miscutils/crond.c +++ b/miscutils/crond.c | |||
@@ -443,7 +443,7 @@ static void FixDayDow(CronLine *line) | |||
443 | 443 | ||
444 | static void SynchronizeFile(const char *fileName) | 444 | static void SynchronizeFile(const char *fileName) |
445 | { | 445 | { |
446 | struct parser_t parser; | 446 | struct parser_t *parser; |
447 | struct stat sbuf; | 447 | struct stat sbuf; |
448 | int maxLines; | 448 | int maxLines; |
449 | char *tokens[6]; | 449 | char *tokens[6]; |
@@ -455,12 +455,13 @@ static void SynchronizeFile(const char *fileName) | |||
455 | return; | 455 | return; |
456 | 456 | ||
457 | DeleteFile(fileName); | 457 | DeleteFile(fileName); |
458 | if (!config_open(&parser, fileName)) | 458 | parser = config_open(fileName); |
459 | if (!parser) | ||
459 | return; | 460 | return; |
460 | 461 | ||
461 | maxLines = (strcmp(fileName, "root") == 0) ? 65535 : MAXLINES; | 462 | maxLines = (strcmp(fileName, "root") == 0) ? 65535 : MAXLINES; |
462 | 463 | ||
463 | if (fstat(fileno(parser.fp), &sbuf) == 0 && sbuf.st_uid == DaemonUid) { | 464 | if (fstat(fileno(parser->fp), &sbuf) == 0 && sbuf.st_uid == DaemonUid) { |
464 | CronFile *file = xzalloc(sizeof(CronFile)); | 465 | CronFile *file = xzalloc(sizeof(CronFile)); |
465 | CronLine **pline; | 466 | CronLine **pline; |
466 | int n; | 467 | int n; |
@@ -468,11 +469,11 @@ static void SynchronizeFile(const char *fileName) | |||
468 | file->cf_User = xstrdup(fileName); | 469 | file->cf_User = xstrdup(fileName); |
469 | pline = &file->cf_LineBase; | 470 | pline = &file->cf_LineBase; |
470 | 471 | ||
471 | while (--maxLines && (n=config_read(&parser, tokens, 6, 0, " \t", '#')) >= 0) { | 472 | while (--maxLines && (n=config_read(parser, tokens, 6, 0, " \t", '#')) >= 0) { |
472 | CronLine *line; | 473 | CronLine *line; |
473 | 474 | ||
474 | if (DebugOpt) { | 475 | if (DebugOpt) { |
475 | crondlog(LVL5 "user:%s entry:%s", fileName, parser.data); | 476 | crondlog(LVL5 "user:%s entry:%s", fileName, parser->data); |
476 | } | 477 | } |
477 | 478 | ||
478 | /* check if line is setting MAILTO= */ | 479 | /* check if line is setting MAILTO= */ |
@@ -519,7 +520,7 @@ static void SynchronizeFile(const char *fileName) | |||
519 | crondlog(WARN9 "user %s: too many lines", fileName); | 520 | crondlog(WARN9 "user %s: too many lines", fileName); |
520 | } | 521 | } |
521 | } | 522 | } |
522 | config_close(&parser); | 523 | config_close(parser); |
523 | } | 524 | } |
524 | 525 | ||
525 | static void CheckUpdates(void) | 526 | static void CheckUpdates(void) |