diff options
author | Guy Harris <gharris@sonic.net> | 2023-06-24 23:35:45 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2023-06-24 23:35:45 -0700 |
commit | 8f1f6fcbe4b4c17d965b42374a2f170452a93289 (patch) | |
tree | 52c8f4835f8ff0ff4c854f5e3c5757020b04caf2 /pcap-nit.c | |
parent | d130479e5b2c024a70e1f7446a228eb19243114e (diff) |
If we can't allocate a DLT_ list, fail.
Some code already was doing that (for example, pcap-bpf.c if fetching
the DLT list with an ioctl), and, if you can't allocate a DLT_ list,
which is usually pretty small, you may have other memory allocation
problems later, so letting the program open an interface (and not get a
correct list of all link-layer types supported) may not be worth it.
Diffstat (limited to 'pcap-nit.c')
-rw-r--r-- | pcap-nit.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -344,14 +344,14 @@ pcap_activate_nit(pcap_t *p) * Ethernet framing). */ p->dlt_list = (u_int *) malloc(sizeof(u_int) * 2); - /* - * If that fails, just leave the list empty. - */ - if (p->dlt_list != NULL) { - p->dlt_list[0] = DLT_EN10MB; - p->dlt_list[1] = DLT_DOCSIS; - p->dlt_count = 2; + if (p->dlt_list == NULL) { + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); + goto bad; } + p->dlt_list[0] = DLT_EN10MB; + p->dlt_list[1] = DLT_DOCSIS; + p->dlt_count = 2; p->read_op = pcap_read_nit; p->inject_op = pcap_inject_nit; |