From: Guy Harris Date: Wed, 26 May 2021 05:26:48 +0000 (-0700) Subject: Frame Relay: have q922_string() handle errors better. X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/51bc4bffb849bd323fcff9a03b8b5492885fe37a?ds=inline Frame Relay: have q922_string() handle errors better. Have it return a string indicating an error, rather than a null string. --- diff --git a/print-fr.c b/print-fr.c index 98f436fe..70b4d0af 100644 --- a/print-fr.c +++ b/print-fr.c @@ -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 ""; + } else if (ret == -1) { + return ""; + } else { + snprintf(buffer, sizeof(buffer), "parse_q922_header() returned %d", ret); + return buffer; } - - return buffer; }