diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-11-15 10:47:24 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-11-15 10:47:24 -0800 |
commit | 7d787482040aa327ef2345eca2e9f980ce76cc28 (patch) | |
tree | a4756446c343f763ab12c0c55b78801d3c28a3f4 /dlpisubs.c | |
parent | 3299e855cb1cf7b6426d70e52cc51a022b9d9141 (diff) | |
download | libpcap-7d787482040aa327ef2345eca2e9f980ce76cc28.tar.gz |
Add a routine to format error messages with an errno-based message at the end.
That routine will use strerror_s() or strerror_r() if available, in a
fashion that's thread-safe. Otherwise, it falls back on
pcap_strerror().
Use it in both libpcap and rpcapd.
Given that we check for errors in strerror_r(), hopefully this will
squelch warnings with newer version of GCC and GNU libc; whilst the
macOS (and other BSD-flavored?) strerror_r() always fills in a message,
that's not required by the Single UNIX Specification, as far as I can
tell, so we apparently really *do* need to check for errors.
Diffstat (limited to 'dlpisubs.c')
-rw-r--r-- | dlpisubs.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -358,7 +358,8 @@ pcap_alloc_databuf(pcap_t *p) p->bufsize = PKTBUFSIZE; p->buffer = malloc(p->bufsize + p->offset); if (p->buffer == NULL) { - strlcpy(p->errbuf, pcap_strerror(errno), PCAP_ERRBUF_SIZE); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, ""); return (-1); } @@ -392,6 +393,6 @@ strioctl(int fd, int cmd, int len, char *dp) static void pcap_stream_err(const char *func, int err, char *errbuf) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", func, pcap_strerror(err)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, err, "%s", func); } #endif |