diff options
author | Guy Harris <guy@alum.mit.edu> | 2020-05-11 23:31:09 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2020-05-11 23:31:09 -0700 |
commit | 1e50a91d583d0ae9780974e05b536b167e37de8e (patch) | |
tree | 9009548489a827c764c9cc589577ab5cf3f00ec9 /pcap-bpf.c | |
parent | 4a793bab1c7f00dfad9bcd99402a12e55cbe8532 (diff) | |
download | libpcap-1e50a91d583d0ae9780974e05b536b167e37de8e.tar.gz |
bpf: in check_setif_failure(), refer to the error code we were passed.
In some places, we referred to "errno" rather than "error"; the latter
is the error code we were passed and which we should check and use in
error messages.
In addition, don't set p->errbuf for ENXIO - that's just "No such
device", and we already return an error code for that - a string saying
BIOCSETIF failed with "Device not configured" adds no useful information
to the one you get for PCAP_ERROR_NO_SUCH_DEVICE.
Diffstat (limited to 'pcap-bpf.c')
-rw-r--r-- | pcap-bpf.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -1588,10 +1588,8 @@ check_setif_failure(pcap_t *p, int error) /* * No such device. */ - pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "BIOCSETIF failed"); return (PCAP_ERROR_NO_SUCH_DEVICE); - } else if (errno == ENETDOWN) { + } else if (error == ENETDOWN) { /* * Return a "network down" indication, so that * the application can report that rather than @@ -1606,7 +1604,7 @@ check_setif_failure(pcap_t *p, int error) * return PCAP_ERROR. */ pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "BIOCSETIF: %s", p->opt.device); + error, "BIOCSETIF: %s", p->opt.device); return (PCAP_ERROR); } } |