From: Willy Tarreau Date: Mon, 13 Sep 2010 20:50:49 +0000 (+0200) Subject: [MINOR] halog: skip non-traffic logs for -st and -tc X-Git-Tag: v1.5-dev8~466 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5417081c798b3356c200cdd5f5daac6b8f666c12;p=thirdparty%2Fhaproxy.git [MINOR] halog: skip non-traffic logs for -st and -tc Those were reporting stupid results in presence of administrative logs. --- diff --git a/contrib/halog/halog.c b/contrib/halog/halog.c index ebdcfcfc4e..016227987c 100644 --- a/contrib/halog/halog.c +++ b/contrib/halog/halog.c @@ -603,7 +603,16 @@ int main(int argc, char **argv) } if (unlikely(filter & FILT_COUNT_STATUS)) { - b = field_start(line, STATUS_FIELD + skip_fields); + /* first, let's ensure that the line is a traffic line (beginning + * with an IP address) + */ + b = field_start(line, SOURCE_FIELD + skip_fields); + if (*b < '0' || *b > '9') { + parse_err++; + continue; + } + + b = field_start(b, STATUS_FIELD - SOURCE_FIELD + 1); if (!*b) { truncated_line(linenum, line); continue; @@ -616,7 +625,16 @@ int main(int argc, char **argv) } if (unlikely(filter & FILT_COUNT_TERM_CODES)) { - b = field_start(line, TERM_CODES_FIELD + skip_fields); + /* first, let's ensure that the line is a traffic line (beginning + * with an IP address) + */ + b = field_start(line, SOURCE_FIELD + skip_fields); + if (*b < '0' || *b > '9') { + parse_err++; + continue; + } + + b = field_start(b, TERM_CODES_FIELD - SOURCE_FIELD + 1); if (!*b) { truncated_line(linenum, line); continue;