]> 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)
committerMichael Richardson <[email protected]>
Mon, 9 Mar 2015 18:23:25 +0000 (14:23 -0400)
netdissect.h

index 4580e73dd26fda80b911028d96d97f01637a0d93..818f8eca2536e407675690cef0d11df9d186f4d1 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))