From d615067ecfe859cadfb09c0896864a4bff299d4f Mon Sep 17 00:00:00 2001 From: ulfl Date: Mon, 8 Aug 2005 18:50:39 +0000 Subject: various code cleanup: -use g_snprintf instead of sprintf and snprintf -use g_strdup_printf where appropriate -remove #include "snprintf.h" (as only g_snprintf should be used) -replace some more alloc/realloc/calloc/free with their glib pendants git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@15264 f5534014-38df-0310-8fa8-9805f1628bb7 --- pcap-util-unix.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'pcap-util-unix.c') diff --git a/pcap-util-unix.c b/pcap-util-unix.c index ae14754aba..9f4a6798d7 100644 --- a/pcap-util-unix.c +++ b/pcap-util-unix.c @@ -93,7 +93,7 @@ get_interface_list(int *err, char *err_str) if (sock < 0) { *err = CANT_GET_INTERFACE_LIST; - sprintf(err_str, "Error opening socket: %s", + g_snprintf(err_str, PCAP_ERRBUF_SIZE, "Error opening socket: %s", strerror(errno)); return NULL; } @@ -111,14 +111,14 @@ get_interface_list(int *err, char *err_str) memset (buf, 0, len); if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) { if (errno != EINVAL || lastlen != 0) { - sprintf(err_str, + g_snprintf(err_str, PCAP_ERRBUF_SIZE, "SIOCGIFCONF ioctl error getting list of interfaces: %s", strerror(errno)); goto fail; } } else { if ((unsigned) ifc.ifc_len < sizeof(struct ifreq)) { - sprintf(err_str, + g_snprintf(err_str, PCAP_ERRBUF_SIZE, "SIOCGIFCONF ioctl gave too small return buffer"); goto fail; } @@ -165,7 +165,8 @@ get_interface_list(int *err, char *err_str) if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifrflags) < 0) { if (errno == ENXIO) goto next; - sprintf(err_str, "SIOCGIFFLAGS error getting flags for interface %s: %s", + g_snprintf(err_str, PCAP_ERRBUF_SIZE, + "SIOCGIFFLAGS error getting flags for interface %s: %s", ifr->ifr_name, strerror(errno)); goto fail; } -- cgit v1.2.3