]> The Tcpdump Group git mirrors - tcpdump/commitdiff
ND_TEST2 should validate that l is non-negative
authorMichael Richardson <[email protected]>
Mon, 9 Mar 2015 18:23:25 +0000 (14:23 -0400)
committerGuy Harris <[email protected]>
Wed, 11 Mar 2015 06:11:25 +0000 (23:11 -0700)
netdissect.h

index b25f4c9fd5e79487f4d22e9858deb63b8f42bec3..7b8b5f4a1ecf382c24bee111052651a644a5fdca 100644 (file)
@@ -271,8 +271,9 @@ struct netdissect_options {
  *     http://www.kb.cert.org/vuls/id/162289
  */
 #define ND_TTEST2(var, l) \
+  ((l) >= 0 && \
        ((uintptr_t)ndo->ndo_snapend - (l) <= (uintptr_t)ndo->ndo_snapend && \
-           (uintptr_t)&(var) <= (uintptr_t)ndo->ndo_snapend - (l))
+         (uintptr_t)&(var) <= (uintptr_t)ndo->ndo_snapend - (l)))
 
 /* True if "var" was captured */
 #define ND_TTEST(var) ND_TTEST2(var, sizeof(var))