summaryrefslogtreecommitdiff
path: root/netdissect.h
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2022-03-29 00:51:21 -0700
committerGuy Harris <gharris@sonic.net>2022-03-29 00:51:21 -0700
commitbe43281053727d9a32c479813fd0ec79bdaf2dda (patch)
treee054f7f33cd3a898f5610800015c24fb276e9bcc /netdissect.h
parent518e1bf60b5a72f29593e00a535f0a563d5d077b (diff)
downloadtcpdump-be43281053727d9a32c479813fd0ec79bdaf2dda.tar.gz
Make sure we don't set the snapend before the beginning of the packet.
If a caller attempts to set it after the current snapend, just silently ignore the attempt. If they try to set it before the beginning of the packet, report it as a bug and quit dissection. Add a new setjmp() return value meaning "bug" rather than "truncated packet", add an "nd_bug_longjmp()" routine for reporting bugs where we should quit dissecting, and use that in this case.
Diffstat (limited to 'netdissect.h')
-rw-r--r--netdissect.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/netdissect.h b/netdissect.h
index e2b77860..605a9c9b 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -193,7 +193,8 @@ struct netdissect_saved_packet_info {
};
/* 'val' value(s) for longjmp */
-#define ND_TRUNCATED 1
+#define ND_TRUNCATED 1 /* packet data too short */
+#define ND_BUG 2 /* bug of some sort */
struct netdissect_options {
int ndo_bflag; /* print 4 byte ASes in ASDOT notation */
@@ -283,6 +284,20 @@ nd_trunc_longjmp(netdissect_options *ndo)
#endif /* _AIX */
}
+static inline NORETURN void
+nd_bug_longjmp(netdissect_options *ndo)
+{
+ longjmp(ndo->ndo_early_end, ND_BUG);
+#ifdef _AIX
+ /*
+ * In AIX <setjmp.h> decorates longjmp() with "#pragma leaves", which tells
+ * XL C that the function is noreturn, but GCC remains unaware of that and
+ * yields a "'noreturn' function does return" warning.
+ */
+ ND_UNREACHABLE
+#endif /* _AIX */
+}
+
#define PT_VAT 1 /* Visual Audio Tool */
#define PT_WB 2 /* distributed White Board */
#define PT_RPC 3 /* Remote Procedure Call */