- 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
This commit is contained in:
@ -443,7 +443,7 @@ static void FixDayDow(CronLine *line)
|
||||
|
||||
static void SynchronizeFile(const char *fileName)
|
||||
{
|
||||
struct parser_t parser;
|
||||
struct parser_t *parser;
|
||||
struct stat sbuf;
|
||||
int maxLines;
|
||||
char *tokens[6];
|
||||
@ -455,12 +455,13 @@ static void SynchronizeFile(const char *fileName)
|
||||
return;
|
||||
|
||||
DeleteFile(fileName);
|
||||
if (!config_open(&parser, fileName))
|
||||
parser = config_open(fileName);
|
||||
if (!parser)
|
||||
return;
|
||||
|
||||
maxLines = (strcmp(fileName, "root") == 0) ? 65535 : MAXLINES;
|
||||
|
||||
if (fstat(fileno(parser.fp), &sbuf) == 0 && sbuf.st_uid == DaemonUid) {
|
||||
if (fstat(fileno(parser->fp), &sbuf) == 0 && sbuf.st_uid == DaemonUid) {
|
||||
CronFile *file = xzalloc(sizeof(CronFile));
|
||||
CronLine **pline;
|
||||
int n;
|
||||
@ -468,11 +469,11 @@ static void SynchronizeFile(const char *fileName)
|
||||
file->cf_User = xstrdup(fileName);
|
||||
pline = &file->cf_LineBase;
|
||||
|
||||
while (--maxLines && (n=config_read(&parser, tokens, 6, 0, " \t", '#')) >= 0) {
|
||||
while (--maxLines && (n=config_read(parser, tokens, 6, 0, " \t", '#')) >= 0) {
|
||||
CronLine *line;
|
||||
|
||||
if (DebugOpt) {
|
||||
crondlog(LVL5 "user:%s entry:%s", fileName, parser.data);
|
||||
crondlog(LVL5 "user:%s entry:%s", fileName, parser->data);
|
||||
}
|
||||
|
||||
/* check if line is setting MAILTO= */
|
||||
@ -519,7 +520,7 @@ static void SynchronizeFile(const char *fileName)
|
||||
crondlog(WARN9 "user %s: too many lines", fileName);
|
||||
}
|
||||
}
|
||||
config_close(&parser);
|
||||
config_close(parser);
|
||||
}
|
||||
|
||||
static void CheckUpdates(void)
|
||||
|
Reference in New Issue
Block a user