diff --git a/ChangeLog b/ChangeLog index ee91c11e..a2fe975d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ v0.71.4 12-Aug-2005 Added extra debug logging to trace an SIGSEG when forwarding files. Added error logmessage in case *.msg path isn't defined. + Fixed a segfault when echomail.jam or netmail.jam is corrupted + when scanning for outgoing mail. v0.71.3 13-Jun-2005 - 12-Aug-2005 diff --git a/mbfido/scan.c b/mbfido/scan.c index aceaa813..aa6515a2 100644 --- a/mbfido/scan.c +++ b/mbfido/scan.c @@ -77,7 +77,7 @@ void ScanMail(int DoAll) { int DoFull = FALSE, i = 0; unsigned long msg; - char *Fname = NULL, *temp, *path; + char *Fname = NULL, *temp, *msgstr, *path; FILE *fp; if (DoAll) { @@ -90,11 +90,16 @@ void ScanMail(int DoAll) sprintf(Fname, "%s/tmp/echomail.jam", getenv("MBSE_ROOT")); if ((fp = fopen(Fname, "r")) != NULL) { while ((fgets(temp, PATH_MAX - 1, fp)) != NULL) { - path = strtok(temp, " "); - msg = atol(strtok(NULL, "\n")); - Syslog('+', "Export message %lu from %s", msg, path); - ScanOne(path, msg); - i++; + path = strtok(temp, " \n\0"); + msgstr = strtok(NULL, "\n\0"); + if (path && msgstr) { + msg = atol(msgstr); + Syslog('+', "Export message %lu from %s", msg, path); + ScanOne(path, msg); + i++; + } else { + Syslog('!', "Ignored garbage line in %s", Fname); + } Nopper(); } fclose(fp); @@ -104,11 +109,16 @@ void ScanMail(int DoAll) sprintf(Fname, "%s/tmp/netmail.jam", getenv("MBSE_ROOT")); if ((fp = fopen(Fname, "r")) != NULL) { while ((fgets(temp, PATH_MAX - 1, fp)) != NULL) { - path = strtok(temp, " "); - msg = atol(strtok(NULL, "\n")); - Syslog('+', "Export message %lu from %s", msg, path); - ScanOne(path, msg); - i++; + path = strtok(temp, " \n\0"); + msgstr = strtok(NULL, "\n\0"); + if (path && msgstr) { + msg = atol(msgstr); + Syslog('+', "Export message %lu from %s", msg, path); + ScanOne(path, msg); + i++; + } else { + Syslog('!', "Ignored garbage line in %s", Fname); + } Nopper(); } fclose(fp);