summaryrefslogtreecommitdiff
path: root/print-ipfc.c
diff options
context:
space:
mode:
authorFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2018-02-12 10:49:08 +0100
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2018-02-12 11:03:47 +0100
commit0d35fd46a18909afce7dd9cf8041165d769e97d4 (patch)
tree4579890d0ea9050a724666d5654edc253bcf174e /print-ipfc.c
parent9d7fa2e15a2a4a13b00b69341471bfab1ba2fa4c (diff)
downloadtcpdump-0d35fd46a18909afce7dd9cf8041165d769e97d4.tar.gz
IPFC: Add a bounds check
Moreover: Add and use tstr[]. Fix indent.
Diffstat (limited to 'print-ipfc.c')
-rw-r--r--print-ipfc.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/print-ipfc.c b/print-ipfc.c
index 6c751380..358bf0ba 100644
--- a/print-ipfc.c
+++ b/print-ipfc.c
@@ -34,6 +34,8 @@
#include "netdissect.h"
#include "addrtoname.h"
+static const char tstr[] = " [|ipfc]";
+
struct ipfc_header {
nd_byte ipfc_dhost[2+MAC_ADDR_LEN];
nd_byte ipfc_shost[2+MAC_ADDR_LEN];
@@ -44,7 +46,7 @@ struct ipfc_header {
/* Extract src, dst addresses */
static void
extract_ipfc_addrs(const struct ipfc_header *ipfcp, char *ipfcsrc,
- char *ipfcdst)
+ char *ipfcdst)
{
/*
* We assume that, as per RFC 2625, the lower 48 bits of the
@@ -59,9 +61,8 @@ extract_ipfc_addrs(const struct ipfc_header *ipfcp, char *ipfcsrc,
*/
static void
ipfc_hdr_print(netdissect_options *ndo,
- const struct ipfc_header *ipfcp _U_,
- u_int length, const u_char *ipfcsrc,
- const u_char *ipfcdst)
+ const struct ipfc_header *ipfcp _U_, u_int length,
+ const u_char *ipfcsrc, const u_char *ipfcdst)
{
const char *srcname, *dstname;
@@ -94,13 +95,12 @@ ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
struct lladdr_info src, dst;
int llc_hdrlen;
- if (caplen < IPFC_HDRLEN) {
- ND_PRINT("[|ipfc]");
- return (caplen);
- }
+ if (caplen < IPFC_HDRLEN)
+ goto trunc;
/*
* Get the network addresses into a canonical form
*/
+ ND_TCHECK_SIZE(ipfcp);
extract_ipfc_addrs(ipfcp, (char *)srcmac, (char *)dstmac);
if (ndo->ndo_eflag)
@@ -128,6 +128,9 @@ ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
llc_hdrlen = -llc_hdrlen;
}
return (IPFC_HDRLEN + llc_hdrlen);
+trunc:
+ ND_PRINT("%s", tstr);
+ return caplen;
}
/*