]> The Tcpdump Group git mirrors - tcpdump/commitdiff
syslog: squelch a cppcheck warning (GH #568)
authorDenis Ovsienko <[email protected]>
Tue, 5 Sep 2017 22:03:21 +0000 (23:03 +0100)
committerDenis Ovsienko <[email protected]>
Tue, 5 Sep 2017 22:03:21 +0000 (23:03 +0100)
[print-syslog.c:98]: (style) Array index 'msg_off' is used before limits
check.

Even though this is a false positive in this specific case, let's not
have it around, this will make it less likely missing a real one.

print-syslog.c

index 1756aa6f0ba60822e52f5f2b28202a972f00ea1b..4f613f0ac0673f2a6e9e9f9cc607e5e3e7bbb8df 100644 (file)
@@ -94,9 +94,9 @@ syslog_print(netdissect_options *ndo,
     if (*(pptr+msg_off) == '<') {
         msg_off++;
         ND_TCHECK2(*(pptr + msg_off), 1);
-        while ( *(pptr+msg_off) >= '0' &&
-                *(pptr+msg_off) <= '9' &&
-                msg_off <= SYSLOG_MAX_DIGITS) {
+        while (msg_off <= SYSLOG_MAX_DIGITS &&
+               *(pptr+msg_off) >= '0' &&
+               *(pptr+msg_off) <= '9') {
             pri = pri * 10 + (*(pptr+msg_off) - '0');
             msg_off++;
             ND_TCHECK2(*(pptr + msg_off), 1);