summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2019-08-18 14:55:11 +0200
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2019-08-18 15:17:07 +0200
commitf50b5d79085dd3c5212b52a99697cb4ccd4dea6d (patch)
treeac2b77f8e86d3fad207e802ac1620f2cd9634e1d
parentab450fb62de1125fbaa24d0e46c62c88323bea81 (diff)
downloadtcpdump-f50b5d79085dd3c5212b52a99697cb4ccd4dea6d.tar.gz
LDP: Fix an undefined behavior at runtime
The error was: print-ldp.c:557:13: runtime error: unsigned integer overflow: 32 - 34 cannot be represented in type 'unsigned int'
-rw-r--r--print-ldp.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/print-ldp.c b/print-ldp.c
index 680a7e1e..49379f0d 100644
--- a/print-ldp.c
+++ b/print-ldp.c
@@ -211,7 +211,7 @@ static const struct tok ldp_fec_martini_ifparm_vccv_cv_values[] = {
{ 0, NULL}
};
-static int ldp_pdu_print(netdissect_options *, const u_char *);
+static u_int ldp_pdu_print(netdissect_options *, const u_char *);
/*
* ldp tlv header
@@ -547,19 +547,24 @@ void
ldp_print(netdissect_options *ndo,
const u_char *pptr, u_int len)
{
- int processed;
+ u_int processed;
ndo->ndo_protocol = "ldp";
while (len > (sizeof(struct ldp_common_header) + sizeof(struct ldp_msg_header))) {
processed = ldp_pdu_print(ndo, pptr);
if (processed == 0)
return;
+ if (len < processed) {
+ ND_PRINT(" [remaining length %u < %u]", len, processed);
+ nd_print_invalid(ndo);
+ break;
+ }
len -= processed;
pptr += processed;
}
}
-static int
+static u_int
ldp_pdu_print(netdissect_options *ndo,
const u_char *pptr)
{