From 11977871358e70c3aa5cddc20904a74ee85ebd57 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 27 May 2011 14:27:07 +0200 Subject: [PATCH] Make sure return value of fgetc isn't truncated. --- src/util-threshold-config.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/util-threshold-config.c b/src/util-threshold-config.c index 10de306ebf..19b95ed2f8 100644 --- a/src/util-threshold-config.c +++ b/src/util-threshold-config.c @@ -606,7 +606,7 @@ int SCThresholdConfLineIsMultiline(char *line) int SCThresholdConfLineLength(FILE *fd) { int pos = ftell(fd); int len = 0; - char c; + int c; while ( (c = fgetc(fd)) && c != '\n' && !feof(fd)) len++; @@ -625,7 +625,7 @@ void SCThresholdConfParseFile(DetectEngineCtx *de_ctx, FILE *fd) { char *line = NULL; int len = 0; - char c; + int c; int rule_num = 0; /* position of "\", on multiline rules */ @@ -648,7 +648,8 @@ void SCThresholdConfParseFile(DetectEngineCtx *de_ctx, FILE *fd) break; } - if (fgets(line + esc_pos, len + 1, fd) == NULL) break; + if (fgets(line + esc_pos, len + 1, fd) == NULL) + break; /* Skip EOL to inspect the next line (or read EOF) */ c = fgetc(fd);