]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Fix potential iprep file parsing issue (2).
authorVictor Julien <victor@inliniac.net>
Wed, 6 Mar 2013 14:35:25 +0000 (15:35 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 6 Mar 2013 14:35:25 +0000 (15:35 +0100)
src/reputation.c

index fec8a08746d49825b889a31af8eb41363fda5f0a..6b62f3012dd998ae51747ec9e5698634fad187f5 100644 (file)
@@ -298,6 +298,8 @@ static int SRepLoadFile(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')
@@ -307,7 +309,10 @@ static int SRepLoadFile(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';
         }