From cb7febd0d1147cd307db61ab4ef8fdd46ca87239 Mon Sep 17 00:00:00 2001 From: marcus Date: Sat, 3 Jan 2004 04:29:55 +0000 Subject: * Don't use SOCK_STREAM when SOCK_DGRAM will do * Fix a potential memory leak git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@1582 df743ca5-7f9a-e211-a948-0013205c9059 --- net/gnome-netstatus/Makefile | 1 + net/gnome-netstatus/files/patch-src_netstatus-iface.c | 15 ++++++--------- net/gnome-netstatus/files/patch-src_netstatus-sysdeps.c | 5 +++-- net/gnomenetstatus/Makefile | 1 + net/gnomenetstatus/files/patch-src_netstatus-iface.c | 15 ++++++--------- net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c | 5 +++-- 6 files changed, 20 insertions(+), 22 deletions(-) (limited to 'net') diff --git a/net/gnome-netstatus/Makefile b/net/gnome-netstatus/Makefile index b7b8ddc66..4c5494cb6 100644 --- a/net/gnome-netstatus/Makefile +++ b/net/gnome-netstatus/Makefile @@ -7,6 +7,7 @@ PORTNAME= gnomenetstatus PORTVERSION= 0.12 +PORTREVISION= 1 CATEGORIES= net gnome MASTER_SITES= ${MASTER_SITE_GNOME} MASTER_SITE_SUBDIR= sources/gnome-netstatus/0.12 diff --git a/net/gnome-netstatus/files/patch-src_netstatus-iface.c b/net/gnome-netstatus/files/patch-src_netstatus-iface.c index 87a75d3db..f33269915 100644 --- a/net/gnome-netstatus/files/patch-src_netstatus-iface.c +++ b/net/gnome-netstatus/files/patch-src_netstatus-iface.c @@ -1,5 +1,5 @@ --- src/netstatus-iface.c.orig Fri Oct 31 08:49:51 2003 -+++ src/netstatus-iface.c Sat Dec 6 01:17:12 2003 ++++ src/netstatus-iface.c Fri Jan 2 23:29:27 2004 @@ -32,9 +32,12 @@ #include @@ -51,7 +51,7 @@ } gboolean -@@ -1083,10 +1095,13 @@ +@@ -1083,8 +1095,11 @@ struct ifconf *if_conf; GList *interfaces; GList *loopbacks; @@ -62,11 +62,8 @@ + int len; + gboolean loopback; -- if ((fd = socket (AF_INET, SOCK_DGRAM, 0)) < 0) -+ if ((fd = socket (AF_INET, SOCK_STREAM, 0)) < 0) + if ((fd = socket (AF_INET, SOCK_DGRAM, 0)) < 0) { - if (error) - *error = g_error_new (NETSTATUS_ERROR, @@ -1105,12 +1120,25 @@ interfaces = NULL; loopbacks = NULL; @@ -83,8 +80,7 @@ + if (if_req->ifr_addr.sa_len > len) + len = if_req->ifr_addr.sa_len; +#endif - -- if (ioctl (fd, SIOCGIFFLAGS, &if_req) < 0) ++ + ptr += sizeof(if_req->ifr_name) + len; + + if (g_list_find_custom (interfaces, if_req->ifr_name, @@ -92,7 +88,8 @@ + || g_list_find_custom (loopbacks, if_req->ifr_name, + (GCompareFunc) g_ascii_strcasecmp) != NULL) + continue; -+ + +- if (ioctl (fd, SIOCGIFFLAGS, &if_req) < 0) + if (ioctl (fd, SIOCGIFFLAGS, if_req) < 0) { if (error) diff --git a/net/gnome-netstatus/files/patch-src_netstatus-sysdeps.c b/net/gnome-netstatus/files/patch-src_netstatus-sysdeps.c index 5b80d1865..3598a24e6 100644 --- a/net/gnome-netstatus/files/patch-src_netstatus-sysdeps.c +++ b/net/gnome-netstatus/files/patch-src_netstatus-sysdeps.c @@ -1,5 +1,5 @@ --- src/netstatus-sysdeps.c.orig Mon Jun 9 13:18:04 2003 -+++ src/netstatus-sysdeps.c Sat Dec 6 17:25:49 2003 ++++ src/netstatus-sysdeps.c Fri Jan 2 23:29:16 2004 @@ -27,10 +27,13 @@ #include @@ -31,7 +31,7 @@ static inline FILE * get_proc_net_dev_fh (void) { -@@ -206,3 +212,125 @@ +@@ -206,3 +212,126 @@ return error_message; } @@ -145,6 +145,7 @@ + close (pout); + } + else { ++ g_strfreev (command_line); + if (error_message) + g_free (error_message); + error_message = g_strdup_printf ("Error running /usr/bin/netstat for '%s': %s", diff --git a/net/gnomenetstatus/Makefile b/net/gnomenetstatus/Makefile index b7b8ddc66..4c5494cb6 100644 --- a/net/gnomenetstatus/Makefile +++ b/net/gnomenetstatus/Makefile @@ -7,6 +7,7 @@ PORTNAME= gnomenetstatus PORTVERSION= 0.12 +PORTREVISION= 1 CATEGORIES= net gnome MASTER_SITES= ${MASTER_SITE_GNOME} MASTER_SITE_SUBDIR= sources/gnome-netstatus/0.12 diff --git a/net/gnomenetstatus/files/patch-src_netstatus-iface.c b/net/gnomenetstatus/files/patch-src_netstatus-iface.c index 87a75d3db..f33269915 100644 --- a/net/gnomenetstatus/files/patch-src_netstatus-iface.c +++ b/net/gnomenetstatus/files/patch-src_netstatus-iface.c @@ -1,5 +1,5 @@ --- src/netstatus-iface.c.orig Fri Oct 31 08:49:51 2003 -+++ src/netstatus-iface.c Sat Dec 6 01:17:12 2003 ++++ src/netstatus-iface.c Fri Jan 2 23:29:27 2004 @@ -32,9 +32,12 @@ #include @@ -51,7 +51,7 @@ } gboolean -@@ -1083,10 +1095,13 @@ +@@ -1083,8 +1095,11 @@ struct ifconf *if_conf; GList *interfaces; GList *loopbacks; @@ -62,11 +62,8 @@ + int len; + gboolean loopback; -- if ((fd = socket (AF_INET, SOCK_DGRAM, 0)) < 0) -+ if ((fd = socket (AF_INET, SOCK_STREAM, 0)) < 0) + if ((fd = socket (AF_INET, SOCK_DGRAM, 0)) < 0) { - if (error) - *error = g_error_new (NETSTATUS_ERROR, @@ -1105,12 +1120,25 @@ interfaces = NULL; loopbacks = NULL; @@ -83,8 +80,7 @@ + if (if_req->ifr_addr.sa_len > len) + len = if_req->ifr_addr.sa_len; +#endif - -- if (ioctl (fd, SIOCGIFFLAGS, &if_req) < 0) ++ + ptr += sizeof(if_req->ifr_name) + len; + + if (g_list_find_custom (interfaces, if_req->ifr_name, @@ -92,7 +88,8 @@ + || g_list_find_custom (loopbacks, if_req->ifr_name, + (GCompareFunc) g_ascii_strcasecmp) != NULL) + continue; -+ + +- if (ioctl (fd, SIOCGIFFLAGS, &if_req) < 0) + if (ioctl (fd, SIOCGIFFLAGS, if_req) < 0) { if (error) diff --git a/net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c b/net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c index 5b80d1865..3598a24e6 100644 --- a/net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c +++ b/net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c @@ -1,5 +1,5 @@ --- src/netstatus-sysdeps.c.orig Mon Jun 9 13:18:04 2003 -+++ src/netstatus-sysdeps.c Sat Dec 6 17:25:49 2003 ++++ src/netstatus-sysdeps.c Fri Jan 2 23:29:16 2004 @@ -27,10 +27,13 @@ #include @@ -31,7 +31,7 @@ static inline FILE * get_proc_net_dev_fh (void) { -@@ -206,3 +212,125 @@ +@@ -206,3 +212,126 @@ return error_message; } @@ -145,6 +145,7 @@ + close (pout); + } + else { ++ g_strfreev (command_line); + if (error_message) + g_free (error_message); + error_message = g_strdup_printf ("Error running /usr/bin/netstat for '%s': %s", -- cgit v1.2.3