]> The Tcpdump Group git mirrors - tcpdump/blobdiff - netdissect.h
Update ND_BYTES_AVAILABLE_AFTER() macro for better accuracy
[tcpdump] / netdissect.h
index e9fe9dffda045d21c20d0c9cca8a745d70b3abfe..b7aad4c119beeb146a045e76134178d60d7d84d6 100644 (file)
@@ -392,7 +392,7 @@ nd_trunc_longjmp(netdissect_options *ndo)
  * Number of bytes remaining in the captured data, starting at the
  * byte pointed to by the argument.
  */
-#define ND_BYTES_AVAILABLE_AFTER(p) ND_BYTES_BETWEEN((p), ndo->ndo_snapend)
+#define ND_BYTES_AVAILABLE_AFTER(p) ((const u_char *)(p) < ndo->ndo_packetp ? 0 : ND_BYTES_BETWEEN((p), ndo->ndo_snapend))
 
 /* Check length < minimum for invalid packet with a custom message, format %u */
 #define ND_LCHECKMSG_U(length, minimum, what) \