[PATCH] Catch missing EOL at EOF
Christoph Biedl <[email protected]> Thu, 7 Feb 2013 00:37:36 +0100
| Newsgroups | gmane.network.poptop |
|---|---|
| Message-ID | <[email protected]> |
This addresses ticket #35 Description: Catch missing EOL at EOF Author: Christoph Biedl <[email protected]> Bug-Debian: http://bugs.debian.org/567480 --- a/configfile.c +++ b/configfile.c @@ -57,14 +57,18 @@ while ((fgets(buffer, MAX_CONFIG_STRING_SIZE - 1, in)) != NULL) { /* ignore long lines */ if (buffer[(len = strlen(buffer)) - 1] != '\n') { - syslog(LOG_ERR, "Long config file line ignored."); - do - fgets(buffer, MAX_CONFIG_STRING_SIZE - 1, in); - while (buffer[strlen(buffer) - 1] != '\n'); - continue; + if (len >= MAX_CONFIG_STRING_SIZE - 2) { + syslog(LOG_ERR, "Long config file line ignored."); + char *p; + do + p = fgets(buffer, MAX_CONFIG_STRING_SIZE - 1, in); + while (p && buffer[strlen(buffer) - 1] != '\n'); + continue; + } + } else { + len--; /* For the NL at the end */ } - len--; /* For the NL at the end */ while (--len >= 0) if (buffer[len] != ' ' && buffer[len] != '\t') break; ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb