From: Victor Julien Date: Wed, 6 Mar 2013 14:32:53 +0000 (+0100) Subject: Fix potential iprep file parsing issue. X-Git-Tag: suricata-1.4.1~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=754ae8a1bef71046f6496e1f38b343bf8d30677b;p=thirdparty%2Fsuricata.git Fix potential iprep file parsing issue. --- diff --git a/src/reputation.c b/src/reputation.c index 02e41b14a0..fec8a08746 100644 --- a/src/reputation.c +++ b/src/reputation.c @@ -245,6 +245,8 @@ int SRepLoadCatFile(char *filename) { while(fgets(line, (int)sizeof(line), fp) != NULL) { size_t len = strlen(line); + if (len == 0) + continue; /* ignore comments and empty lines */ if (line[0] == '\n' || line [0] == '\r' || line[0] == ' ' || line[0] == '#' || line[0] == '\t') @@ -254,7 +256,10 @@ int SRepLoadCatFile(char *filename) { /* Check if we have a trailing newline, and remove it */ len = strlen(line); - if (len > 0 && (line[len - 1] == '\n' || line[len - 1] == '\r')) { + if (len == 0) + continue; + + if (line[len - 1] == '\n' || line[len - 1] == '\r') { line[len - 1] = '\0'; }