]> The Tcpdump Group git mirrors - tcpdump/commitdiff
DCCP: Fix some undefined behaviors at runtime
authorFrancois-Xavier Le Bail <[email protected]>
Sun, 11 Nov 2018 20:39:25 +0000 (21:39 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Sun, 11 Nov 2018 20:46:08 +0000 (21:46 +0100)
The errors were like:
print-dccp.c:448:4: runtime error: unsigned integer overflow: 20 - 24
cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior print-dccp.c:448:4

print-dccp.c

index af47d60ede8755221e090469691da871f6c500a7..bf1fc28615e5d53951932a6f72a6c15581fb08e4 100644 (file)
@@ -306,7 +306,7 @@ dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
        fixed_hdrlen = dccp_basic_hdr_len(dh);
        if (len < fixed_hdrlen) {
                ND_PRINT("truncated-dccp - %u bytes missing!",
-                         len - fixed_hdrlen);
+                         fixed_hdrlen - len);
                return;
        }
        ND_TCHECK_LEN(dh, fixed_hdrlen);
@@ -370,7 +370,7 @@ dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
                if (len < fixed_hdrlen) {
                        ND_PRINT("truncated-%s - %u bytes missing!",
                                  tok2str(dccp_pkt_type_str, "", dccph_type),
-                                 len - fixed_hdrlen);
+                                 fixed_hdrlen - len);
                        return;
                }
                ND_TCHECK_SIZE(dhr);
@@ -386,7 +386,7 @@ dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
                if (len < fixed_hdrlen) {
                        ND_PRINT("truncated-%s - %u bytes missing!",
                                  tok2str(dccp_pkt_type_str, "", dccph_type),
-                                 len - fixed_hdrlen);
+                                 fixed_hdrlen - len);
                        return;
                }
                ND_TCHECK_SIZE(dhr);
@@ -403,7 +403,7 @@ dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
                if (len < fixed_hdrlen) {
                        ND_PRINT("truncated-%s - %u bytes missing!",
                                  tok2str(dccp_pkt_type_str, "", dccph_type),
-                                 len - fixed_hdrlen);
+                                 fixed_hdrlen - len);
                        return;
                }
                ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "", dccph_type));
@@ -414,7 +414,7 @@ dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
                if (len < fixed_hdrlen) {
                        ND_PRINT("truncated-%s - %u bytes missing!",
                                  tok2str(dccp_pkt_type_str, "", dccph_type),
-                                 len - fixed_hdrlen);
+                                 fixed_hdrlen - len);
                        return;
                }
                ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "", dccph_type));
@@ -425,7 +425,7 @@ dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
                if (len < fixed_hdrlen) {
                        ND_PRINT("truncated-%s - %u bytes missing!",
                                  tok2str(dccp_pkt_type_str, "", dccph_type),
-                                 len - fixed_hdrlen);
+                                 fixed_hdrlen - len);
                        return;
                }
                ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "", dccph_type));
@@ -435,7 +435,7 @@ dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
                if (len < fixed_hdrlen) {
                        ND_PRINT("truncated-%s - %u bytes missing!",
                                  tok2str(dccp_pkt_type_str, "", dccph_type),
-                                 len - fixed_hdrlen);
+                                 fixed_hdrlen - len);
                        return;
                }
                ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "", dccph_type));
@@ -447,7 +447,7 @@ dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
                if (len < fixed_hdrlen) {
                        ND_PRINT("truncated-%s - %u bytes missing!",
                                  tok2str(dccp_pkt_type_str, "", dccph_type),
-                                 len - fixed_hdrlen);
+                                 fixed_hdrlen - len);
                        return;
                }
                ND_TCHECK_SIZE(dhr);
@@ -461,7 +461,7 @@ dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
                if (len < fixed_hdrlen) {
                        ND_PRINT("truncated-%s - %u bytes missing!",
                                  tok2str(dccp_pkt_type_str, "", dccph_type),
-                                 len - fixed_hdrlen);
+                                 fixed_hdrlen - len);
                        return;
                }
                ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "", dccph_type));
@@ -471,7 +471,7 @@ dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
                if (len < fixed_hdrlen) {
                        ND_PRINT("truncated-%s - %u bytes missing!",
                                  tok2str(dccp_pkt_type_str, "", dccph_type),
-                                 len - fixed_hdrlen);
+                                 fixed_hdrlen - len);
                        return;
                }
                ND_PRINT("%s ", tok2str(dccp_pkt_type_str, "", dccph_type));