diff options
-rw-r--r-- | etherent.c | 31 | ||||
-rw-r--r-- | pcap-common.c | 7 | ||||
-rw-r--r-- | pcap-netfilter-linux.c | 6 | ||||
-rw-r--r-- | pcap.c | 1 | ||||
-rw-r--r-- | pcap/dlt.h | 6 |
5 files changed, 37 insertions, 14 deletions
@@ -101,16 +101,20 @@ pcap_next_etherent(FILE *fp) static struct pcap_etherent e; memset((char *)&e, 0, sizeof(e)); - do { + for (;;) { /* Find addr */ c = skip_space(fp); + if (c == EOF) + return (NULL); if (c == '\n') continue; /* If this is a comment, or first thing on line - cannot be etehrnet address, skip the line. */ + cannot be Ethernet address, skip the line. */ if (!isxdigit(c)) { c = skip_line(fp); + if (c == EOF) + return (NULL); continue; } @@ -118,25 +122,33 @@ pcap_next_etherent(FILE *fp) for (i = 0; i < 6; i += 1) { d = xdtoi(c); c = getc(fp); + if (c == EOF) + return (NULL); if (isxdigit(c)) { d <<= 4; d |= xdtoi(c); c = getc(fp); + if (c == EOF) + return (NULL); } e.addr[i] = d; if (c != ':') break; c = getc(fp); + if (c == EOF) + return (NULL); } - if (c == EOF) - break; /* Must be whitespace */ if (!isspace(c)) { c = skip_line(fp); + if (c == EOF) + return (NULL); continue; } c = skip_space(fp); + if (c == EOF) + return (NULL); /* hit end of line... */ if (c == '\n') @@ -144,6 +156,8 @@ pcap_next_etherent(FILE *fp) if (c == '#') { c = skip_line(fp); + if (c == EOF) + return (NULL); continue; } @@ -154,7 +168,9 @@ pcap_next_etherent(FILE *fp) do { *bp++ = c; c = getc(fp); - } while (!isspace(c) && c != EOF && --d > 0); + if (c == EOF) + return (NULL); + } while (!isspace(c) && --d > 0); *bp = '\0'; /* Eat trailing junk */ @@ -162,8 +178,5 @@ pcap_next_etherent(FILE *fp) (void)skip_line(fp); return &e; - - } while (c != EOF); - - return (NULL); + } } diff --git a/pcap-common.c b/pcap-common.c index 281203c7..8a34ec85 100644 --- a/pcap-common.c +++ b/pcap-common.c @@ -1063,7 +1063,12 @@ */ #define LINKTYPE_VSOCK 271 -#define LINKTYPE_MATCHING_MAX 271 /* highest value in the "matching" range */ +/* + * Nordic Semiconductor Bluetooth LE sniffer. + */ +#define LINKTYPE_NORDIC_BLE 272 + +#define LINKTYPE_MATCHING_MAX 272 /* highest value in the "matching" range */ static struct linktype_map { int dlt; diff --git a/pcap-netfilter-linux.c b/pcap-netfilter-linux.c index c3d14594..85899559 100644 --- a/pcap-netfilter-linux.c +++ b/pcap-netfilter-linux.c @@ -136,6 +136,9 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c bp = handle->bp; ep = bp + len; while (bp < ep) { + const struct nlmsghdr *nlh = (const struct nlmsghdr *) bp; + u_int32_t msg_len; + nftype_t type = OTHER; /* * Has "pcap_breakloop()" been called? * If so, return immediately - if we haven't read any @@ -162,9 +165,6 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c */ break; } - const struct nlmsghdr *nlh = (const struct nlmsghdr *) bp; - u_int32_t msg_len; - nftype_t type = OTHER; if (nlh->nlmsg_len < sizeof(struct nlmsghdr) || (u_int)len < nlh->nlmsg_len) { pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Message truncated: (got: %d) (nlmsg_len: %u)", len, nlh->nlmsg_len); @@ -2101,6 +2101,7 @@ static struct dlt_choice dlt_choices[] = { DLT_CHOICE(SDLC, "IBM SDLC frames"), DLT_CHOICE(TI_LLN_SNIFFER, "TI LLN sniffer frames"), DLT_CHOICE(VSOCK, "Linux vsock"), + DLT_CHOICE(NORDIC_BLE, "Nordic Semiconductor Bluetooth LE sniffer frames"), DLT_CHOICE_SENTINEL }; @@ -1337,6 +1337,10 @@ */ #define DLT_VSOCK 271 +/* + * Nordic Semiconductor Bluetooth LE sniffer. + */ +#define DLT_NORDIC_BLE 272 /* * In case the code that includes this file (directly or indirectly) @@ -1348,7 +1352,7 @@ #ifdef DLT_MATCHING_MAX #undef DLT_MATCHING_MAX #endif -#define DLT_MATCHING_MAX 271 /* highest value in the "matching" range */ +#define DLT_MATCHING_MAX 272 /* highest value in the "matching" range */ /* * DLT and savefile link type values are split into a class and |