]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Frame Relay: have q922_string() handle errors better.
authorGuy Harris <[email protected]>
Wed, 26 May 2021 05:26:48 +0000 (22:26 -0700)
committerGuy Harris <[email protected]>
Wed, 26 May 2021 05:26:48 +0000 (22:26 -0700)
Have it return a string indicating an error, rather than a null string.

print-fr.c

index 98f436fefd509c7e9141caae0ca1e5fb63ff3b07..70b4d0af93889290eb8430fb2a2df97eaef6e855 100644 (file)
@@ -148,13 +148,21 @@ q922_string(netdissect_options *ndo, const u_char *p, u_int length)
     static u_int dlci, addr_len;
     static uint32_t flags;
     static char buffer[sizeof("DLCI xxxxxxxxxx")];
+    int ret;
     memset(buffer, 0, sizeof(buffer));
 
-    if (parse_q922_header(ndo, p, &dlci, &addr_len, &flags, length) == 1){
+    ret = parse_q922_header(ndo, p, &dlci, &addr_len, &flags, length);
+    if (ret == 1) {
         snprintf(buffer, sizeof(buffer), "DLCI %u", dlci);
+        return buffer;
+    } else if (ret == 0) {
+        return "<Invalid DLCI>";
+    } else if (ret == -1) {
+        return "<Truncated>";
+    } else {
+        snprintf(buffer, sizeof(buffer), "parse_q922_header() returned %d", ret);
+        return buffer;
     }
-
-    return buffer;
 }