* [gentoo-commits] proj/net-tools:gentoo commit in: /
@ 2011-04-09 13:58 Mike Frysinger
0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2011-04-09 13:58 UTC (permalink / raw
To: gentoo-commits
commit: 179168511b347452626a45f543bc1129dcb36db5
Author: Bernd Eckenfels <net-tools <AT> lina <DOT> inka <DOT> de>
AuthorDate: Fri Oct 29 19:24:36 2010 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Oct 29 19:24:36 2010 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=17916851
[Bug #17645] Add netstat(8) support for RcvbufErrors, SndbufErrors.
Thanks jwm
---
statistics.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/statistics.c b/statistics.c
index aa3c3ee..df31d68 100644
--- a/statistics.c
+++ b/statistics.c
@@ -1,6 +1,6 @@
/*
* Copyright 1997,1999,2000 Andi Kleen. Subject to the GPL.
- * $Id: statistics.c,v 1.22 2008/10/03 01:07:47 ecki Exp $
+ * $Id: statistics.c,v 1.23 2010-10-29 19:24:36 ecki Exp $
* 19980630 - i18n - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* 19981113 - i18n fixes - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* 19990101 - added net/netstat, -t, -u, -w supprt - Bernd Eckenfels
@@ -199,7 +199,9 @@ struct entry Udptab[] =
{"NoPorts", N_("%u packets to unknown port received."), number},
{"InErrors", N_("%u packet receive errors"), number},
{"OutDatagrams", N_("%u packets sent"), number},
-};
+ {"RcvbufErrors", N_("%u receive buffer errors"), number},
+ {"SndbufErrors", N_("%u send buffer errors"), number},
+ };
struct entry Udp6tab[] =
{
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/net-tools:gentoo commit in: /
2011-04-09 13:58 [gentoo-commits] proj/net-tools:master " Mike Frysinger
@ 2011-04-09 13:58 ` Mike Frysinger
0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2011-04-09 13:58 UTC (permalink / raw
To: gentoo-commits
commit: 491cedbc9d47a3683f63668e6bc362c17ebf8477
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 9 13:57:28 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Apr 9 13:57:28 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=491cedbc
netstat: split host resolution out from --numeric-ports
According to the manual the option "--numeric-ports" should not
affect host resolution, but it does. All connected hosts are displayed
with numeric values instead of their FQDN.
patch by Mads Martin Joergensen in Gentoo bug 76756
---
netstat.c | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/netstat.c b/netstat.c
index 0acda76..b625d19 100644
--- a/netstat.c
+++ b/netstat.c
@@ -6,7 +6,7 @@
* NET-3 Networking Distribution for the LINUX operating
* system.
*
- * Version: $Id: netstat.c,v 1.71 2011-04-09 13:52:05 vapier Exp $
+ * Version: $Id: netstat.c,v 1.72 2011-04-09 13:57:28 vapier Exp $
*
* Authors: Fred Baumgarten, <dc6iq@insu1.etec.uni-karlsruhe.de>
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
@@ -612,7 +612,7 @@ static void igmp_do_one(int lnr, const char *line,const char *prot)
return;
}
safe_strncpy(mcast_addr, ap->sprint((struct sockaddr *) &mcastaddr,
- flag_not), sizeof(mcast_addr));
+ flag_not & FLAG_NUM_HOST), sizeof(mcast_addr));
printf("%-15s %-6d %s\n", device, refcnt, mcast_addr);
#endif
} else { /* IPV4 */
@@ -650,7 +650,7 @@ static void igmp_do_one(int lnr, const char *line,const char *prot)
return;
}
safe_strncpy(mcast_addr, ap->sprint((struct sockaddr *) &mcastaddr,
- flag_not), sizeof(mcast_addr));
+ flag_not & FLAG_NUM_HOST), sizeof(mcast_addr));
printf("%-15s %-6d %s\n", device, refcnt, mcast_addr );
#endif
} /* IPV4 */
@@ -931,8 +931,8 @@ static void tcp_do_one(int lnr, const char *line, const char *prot)
return;
}
safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr,
- flag_not), sizeof(local_addr));
- safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr, flag_not),
+ flag_not & FLAG_NUM_HOST), sizeof(local_addr));
+ safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr, flag_not & FLAG_NUM_HOST),
sizeof(rem_addr));
snprintf(buffer, sizeof(buffer), "%s",
@@ -1088,7 +1088,7 @@ static void udp_do_one(int lnr, const char *line,const char *prot)
if (flag_all || (notnull(remaddr) && !flag_lst) || (!notnull(remaddr) && flag_lst))
{
safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr,
- flag_not), sizeof(local_addr));
+ flag_not & FLAG_NUM_HOST), sizeof(local_addr));
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(local_port), "udp",
flag_not & FLAG_NUM_PORT));
@@ -1100,7 +1100,7 @@ static void udp_do_one(int lnr, const char *line,const char *prot)
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(rem_port), "udp", flag_not & FLAG_NUM_PORT));
safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr,
- flag_not), sizeof(rem_addr));
+ flag_not & FLAG_NUM_HOST), sizeof(rem_addr));
if ((strlen(rem_addr) + strlen(buffer)) > 22)
rem_addr[22 - strlen(buffer)] = '\0';
strcat(rem_addr, ":");
@@ -1216,7 +1216,7 @@ static void raw_do_one(int lnr, const char *line,const char *prot)
get_sname(htons(local_port), "raw",
flag_not & FLAG_NUM_PORT));
safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr,
- flag_not), sizeof(local_addr));
+ flag_not & FLAG_NUM_HOST), sizeof(local_addr));
if ((strlen(local_addr) + strlen(buffer)) > 22)
local_addr[22 - strlen(buffer)] = '\0';
strcat(local_addr, ":");
@@ -1225,7 +1225,7 @@ static void raw_do_one(int lnr, const char *line,const char *prot)
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(rem_port), "raw", flag_not & FLAG_NUM_PORT));
safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr,
- flag_not), sizeof(rem_addr));
+ flag_not & FLAG_NUM_HOST), sizeof(rem_addr));
if ((strlen(rem_addr) + strlen(buffer)) > 22)
rem_addr[22 - strlen(buffer)] = '\0';
strcat(rem_addr, ":");
@@ -1609,13 +1609,13 @@ static int ipx_info(void)
/* Fetch and resolve the Source */
(void) ap->input(4, sad, &sa);
- safe_strncpy(buf, ap->sprint(&sa, flag_not), sizeof(buf));
+ safe_strncpy(buf, ap->sprint(&sa, flag_not & FLAG_NUM_HOST), sizeof(buf));
snprintf(sad, sizeof(sad), "%s:%04X", buf, sport);
if (!nc) {
/* Fetch and resolve the Destination */
(void) ap->input(4, dad, &sa);
- safe_strncpy(buf, ap->sprint(&sa, flag_not), sizeof(buf));
+ safe_strncpy(buf, ap->sprint(&sa, flag_not & FLAG_NUM_HOST), sizeof(buf));
snprintf(dad, sizeof(dad), "%s:%04X", buf, dport);
} else
strcpy(dad, "-");
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/net-tools:gentoo commit in: /
@ 2011-04-09 13:58 Mike Frysinger
0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2011-04-09 13:58 UTC (permalink / raw
To: gentoo-commits
commit: 65368f77bb04723ce76a44117ae60b0d4715cc42
Author: Steve Grubb <linux_4ever <AT> yahoo <DOT> com>
AuthorDate: Mon Apr 14 04:39:09 2008 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Apr 9 13:57:45 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=65368f77
prevent overflows in interface buffers
Fix originally from Steve Grubb:
URL: https://bugzilla.redhat.com/120343
But later fixed by Rafał Mużyło <galtgendo <AT> o2.pl>:
URL: https://bugs.gentoo.org/298912#c3
---
netstat.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/netstat.c b/netstat.c
index b625d19..412548c 100644
--- a/netstat.c
+++ b/netstat.c
@@ -945,7 +945,7 @@ static void tcp_do_one(int lnr, const char *line, const char *prot)
}
strcat(local_addr, ":");
- strcat(local_addr, buffer);
+ strncat(local_addr, buffer, sizeof(local_addr)-strlen(local_addr)-1);
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(rem_port), "tcp", flag_not & FLAG_NUM_PORT));
@@ -955,7 +955,7 @@ static void tcp_do_one(int lnr, const char *line, const char *prot)
}
strcat(rem_addr, ":");
- strcat(rem_addr, buffer);
+ strncat(rem_addr, buffer, sizeof(rem_addr)-strlen(rem_addr)-1);
timers[0] = '\0';
if (flag_opt)
@@ -1095,7 +1095,7 @@ static void udp_do_one(int lnr, const char *line,const char *prot)
if ((strlen(local_addr) + strlen(buffer)) > 22)
local_addr[22 - strlen(buffer)] = '\0';
strcat(local_addr, ":");
- strcat(local_addr, buffer);
+ strncat(local_addr, buffer, sizeof(local_addr)-strlen(local_addr)-1);
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(rem_port), "udp", flag_not & FLAG_NUM_PORT));
@@ -1104,7 +1104,7 @@ static void udp_do_one(int lnr, const char *line,const char *prot)
if ((strlen(rem_addr) + strlen(buffer)) > 22)
rem_addr[22 - strlen(buffer)] = '\0';
strcat(rem_addr, ":");
- strcat(rem_addr, buffer);
+ strncat(rem_addr, buffer, sizeof(rem_addr)-strlen(rem_addr)-1);
timers[0] = '\0';
if (flag_opt)
@@ -1220,7 +1220,7 @@ static void raw_do_one(int lnr, const char *line,const char *prot)
if ((strlen(local_addr) + strlen(buffer)) > 22)
local_addr[22 - strlen(buffer)] = '\0';
strcat(local_addr, ":");
- strcat(local_addr, buffer);
+ strncat(local_addr, buffer, sizeof(local_addr)-strlen(local_addr)-1);
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(rem_port), "raw", flag_not & FLAG_NUM_PORT));
@@ -1229,7 +1229,7 @@ static void raw_do_one(int lnr, const char *line,const char *prot)
if ((strlen(rem_addr) + strlen(buffer)) > 22)
rem_addr[22 - strlen(buffer)] = '\0';
strcat(rem_addr, ":");
- strcat(rem_addr, buffer);
+ strncat(rem_addr, buffer, sizeof(rem_addr)-strlen(rem_addr)-1);
timers[0] = '\0';
if (flag_opt)
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/net-tools:gentoo commit in: /
2011-04-09 13:58 [gentoo-commits] proj/net-tools:master " Mike Frysinger
@ 2011-04-09 13:58 ` Mike Frysinger
0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2011-04-09 13:58 UTC (permalink / raw
To: gentoo-commits
commit: 74b2b5487338d65c468f76a7530c8c38692b56a1
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 9 13:52:05 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Apr 9 13:52:05 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=74b2b548
netstat: fix handling of large socket numbers
The kernel really only treats sockets with a value of -1 as an error.
The rest are an unsigned quantity. So tweak the nestat lookup to use
an unsigned value.
patch based on Antonio Galea's work in Debian bug 345331
---
netstat.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/netstat.c b/netstat.c
index 5721c1c..0acda76 100644
--- a/netstat.c
+++ b/netstat.c
@@ -6,7 +6,7 @@
* NET-3 Networking Distribution for the LINUX operating
* system.
*
- * Version: $Id: netstat.c,v 1.70 2010-08-15 16:09:31 vapier Exp $
+ * Version: $Id: netstat.c,v 1.71 2011-04-09 13:52:05 vapier Exp $
*
* Authors: Fred Baumgarten, <dc6iq@insu1.etec.uni-karlsruhe.de>
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
@@ -326,8 +326,8 @@ static int extract_type_1_socket_inode(const char lname[], unsigned long * inode
strncpy(inode_str, lname+PRG_SOCKET_PFXl, inode_str_len);
inode_str[inode_str_len] = '\0';
- *inode_p = strtol(inode_str,&serr,0);
- if (!serr || *serr || *inode_p < 0 || *inode_p >= LONG_MAX)
+ *inode_p = strtoul(inode_str, &serr, 0);
+ if (!serr || *serr || *inode_p == ~0)
return(-1);
}
return(0);
@@ -347,8 +347,8 @@ static int extract_type_2_socket_inode(const char lname[], unsigned long * inode
{
char *serr;
- *inode_p=strtol(lname + PRG_SOCKET_PFX2l,&serr,0);
- if (!serr || *serr || *inode_p < 0 || *inode_p >= LONG_MAX)
+ *inode_p = strtoul(lname + PRG_SOCKET_PFX2l, &serr, 0);
+ if (!serr || *serr || *inode_p == ~0)
return(-1);
}
return(0);
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/net-tools:gentoo commit in: /
2011-04-09 13:58 [gentoo-commits] proj/net-tools:master " Mike Frysinger
@ 2011-04-09 13:58 ` Mike Frysinger
0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2011-04-09 13:58 UTC (permalink / raw
To: gentoo-commits
commit: 8022436648fc84b5015dec20339ddd58b9fbfcdf
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 9 13:33:13 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Apr 9 13:33:13 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=80224366
hostname: fix FQDN handling with AAAA records
patch by pasi.valminen <AT> hut.fi
Gentoo bug 42650
---
hostname.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 59 insertions(+), 8 deletions(-)
diff --git a/hostname.c b/hostname.c
index c4c5aa0..4d87b4e 100644
--- a/hostname.c
+++ b/hostname.c
@@ -44,6 +44,11 @@
#include "version.h"
#include "../intl.h"
+#if HAVE_AFINET6
+#include <sys/socket.h> /* for PF_INET6 */
+#include <sys/types.h> /* for inet_ntop */
+#endif
+
#if HAVE_AFDECnet
#include <netdnet/dn.h>
#endif
@@ -125,15 +130,23 @@ static void setdname(char *dname)
static void showhname(char *hname, int c)
{
struct hostent *hp;
+#if HAVE_AFINET6
+ struct in6_addr **ip6;
+#endif
register char *p, **alias;
struct in_addr **ip;
if (opt_v)
fprintf(stderr, _("Resolving `%s' ...\n"), hname);
- if (!(hp = gethostbyname(hname))) {
+ if (
+#if HAVE_AFINET6
+ !(hp = gethostbyname2(hname, PF_INET6)) &&
+#endif
+ !(hp = gethostbyname(hname))) {
herror(program_name);
exit(1);
}
+
if (opt_v) {
fprintf(stderr, _("Result: h_name=`%s'\n"),
hp->h_name);
@@ -142,11 +155,28 @@ static void showhname(char *hname, int c)
while (alias[0])
fprintf(stderr, _("Result: h_aliases=`%s'\n"),
*alias++);
-
- ip = (struct in_addr **) hp->h_addr_list;
- while (ip[0])
- fprintf(stderr, _("Result: h_addr_list=`%s'\n"),
- inet_ntoa(**ip++));
+#if HAVE_AFINET6
+ if (hp->h_addrtype == PF_INET6) {
+ char addr[INET6_ADDRSTRLEN + 1];
+ addr[INET6_ADDRSTRLEN] = '\0';
+ ip6 = (struct in6_addr **) hp->h_addr_list;
+ while (ip6[0]) {
+ if (inet_ntop(PF_INET6, *ip6++, addr, INET6_ADDRSTRLEN))
+ fprintf(stderr, _("Result: h_addr_list=`%s'\n"), addr);
+ else if (errno == EAFNOSUPPORT)
+ fprintf(stderr, _("%s: protocol family not supported\n"),
+ program_name);
+ else if (errno == ENOSPC)
+ fprintf(stderr, _("%s: name too long\n"), program_name);
+ }
+ } else
+#endif
+ {
+ ip = (struct in_addr **) hp->h_addr_list;
+ while (ip[0])
+ fprintf(stderr, _("Result: h_addr_list=`%s'\n"),
+ inet_ntoa(**ip++));
+ }
}
if (!(p = strchr(hp->h_name, '.')) && (c == 'd'))
return;
@@ -158,8 +188,29 @@ static void showhname(char *hname, int c)
printf("\n");
break;
case 'i':
- while (hp->h_addr_list[0])
- printf("%s ", inet_ntoa(*(struct in_addr *) *hp->h_addr_list++));
+#if HAVE_AFINET6
+ if (hp->h_addrtype == PF_INET6) {
+ char addr[INET6_ADDRSTRLEN + 1];
+ addr[INET6_ADDRSTRLEN] = '\0';
+ while (hp->h_addr_list[0]) {
+ if (inet_ntop(PF_INET6, (struct in6_addr *)*hp->h_addr_list++,
+ addr, INET6_ADDRSTRLEN)) {
+ printf("%s ", addr);
+ } else if (errno == EAFNOSUPPORT) {
+ fprintf(stderr, _("\n%s: protocol family not supported\n"),
+ program_name);
+ exit(1);
+ } else if (errno == ENOSPC) {
+ fprintf(stderr, _("\n%s: name too long\n"), program_name);
+ exit(1);
+ }
+ }
+ } else
+#endif
+ {
+ while (hp->h_addr_list[0])
+ printf("%s ", inet_ntoa(*(struct in_addr *)*hp->h_addr_list++));
+ }
printf("\n");
break;
case 'd':
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/net-tools:gentoo commit in: /
2011-08-20 4:57 [gentoo-commits] proj/net-tools:master " Mike Frysinger
@ 2011-08-20 4:57 ` Mike Frysinger
0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2011-08-20 4:57 UTC (permalink / raw
To: gentoo-commits
commit: 5888d1b3d53b209cc3f22d9d33f5149909dc5ca1
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 20 04:56:17 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Aug 20 04:56:17 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=5888d1b3
fix path to net-features.h
This was causing the %.o rule to get ignored which meant most of the
dependencies were ignored.
Once that gets fixed, we see that the %.o rule doesn't properly use
$(CPPFLAGS). So add that while we're here.
Gentoo bug 379715
---
Makefile | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 798509d..afd01e6 100644
--- a/Makefile
+++ b/Makefile
@@ -126,8 +126,8 @@ LD = $(CC)
NLIB = -l$(NET_LIB_NAME)
-%.o: %.c config.h version.h intl.h net-features.h $<
- $(CC) $(CFLAGS) -c $<
+%.o: %.c config.h version.h intl.h lib/net-features.h $<
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $<
all: config.h version.h subdirs $(PROGS)
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/net-tools:gentoo commit in: /
2011-08-20 4:57 [gentoo-commits] proj/net-tools:master " Mike Frysinger
@ 2011-08-20 4:57 ` Mike Frysinger
0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2011-08-20 4:57 UTC (permalink / raw
To: gentoo-commits
commit: 11310f89de97e5adc31462647fe360a9bf970c26
Author: Bernd Eckenfels <net-tools <AT> lina <DOT> inka <DOT> de>
AuthorDate: Wed Apr 20 01:35:22 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Wed Apr 20 01:35:22 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=11310f89
patch from Bert Wesarg to separate basename of -p only if it is absulote
path (in order to make argv[0]="sshd pty/0" display as sshd, and not as /0.
---
netstat.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/netstat.c b/netstat.c
index b625d19..7b45fc8 100644
--- a/netstat.c
+++ b/netstat.c
@@ -6,7 +6,7 @@
* NET-3 Networking Distribution for the LINUX operating
* system.
*
- * Version: $Id: netstat.c,v 1.72 2011-04-09 13:57:28 vapier Exp $
+ * Version: $Id: netstat.c,v 1.73 2011-04-20 01:35:22 ecki Exp $
*
* Authors: Fred Baumgarten, <dc6iq@insu1.etec.uni-karlsruhe.de>
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
@@ -420,7 +420,7 @@ static void prg_cache_load(void)
continue;
if (cmdllen < sizeof(cmdlbuf) - 1)
cmdlbuf[cmdllen]='\0';
- if ((cmdlp = strrchr(cmdlbuf, '/')))
+ if (cmdlbuf[0] == '/' && (cmdlp = strrchr(cmdlbuf, '/')))
cmdlp++;
else
cmdlp = cmdlbuf;
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/net-tools:gentoo commit in: /
@ 2011-08-20 4:57 Mike Frysinger
0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2011-08-20 4:57 UTC (permalink / raw
To: gentoo-commits
commit: 21ca1ba3e5fc5f8e56cab7fdf67528932e3f5a87
Author: Steve Grubb <linux_4ever <AT> yahoo <DOT> com>
AuthorDate: Mon Apr 14 04:39:09 2008 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Aug 20 04:57:29 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=21ca1ba3
prevent overflows in interface buffers
Fix originally from Steve Grubb:
URL: https://bugzilla.redhat.com/120343
But later fixed by Rafał Mużyło <galtgendo <AT> o2.pl>:
URL: https://bugs.gentoo.org/298912#c3
---
netstat.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/netstat.c b/netstat.c
index 7b45fc8..4a4a147 100644
--- a/netstat.c
+++ b/netstat.c
@@ -945,7 +945,7 @@ static void tcp_do_one(int lnr, const char *line, const char *prot)
}
strcat(local_addr, ":");
- strcat(local_addr, buffer);
+ strncat(local_addr, buffer, sizeof(local_addr)-strlen(local_addr)-1);
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(rem_port), "tcp", flag_not & FLAG_NUM_PORT));
@@ -955,7 +955,7 @@ static void tcp_do_one(int lnr, const char *line, const char *prot)
}
strcat(rem_addr, ":");
- strcat(rem_addr, buffer);
+ strncat(rem_addr, buffer, sizeof(rem_addr)-strlen(rem_addr)-1);
timers[0] = '\0';
if (flag_opt)
@@ -1095,7 +1095,7 @@ static void udp_do_one(int lnr, const char *line,const char *prot)
if ((strlen(local_addr) + strlen(buffer)) > 22)
local_addr[22 - strlen(buffer)] = '\0';
strcat(local_addr, ":");
- strcat(local_addr, buffer);
+ strncat(local_addr, buffer, sizeof(local_addr)-strlen(local_addr)-1);
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(rem_port), "udp", flag_not & FLAG_NUM_PORT));
@@ -1104,7 +1104,7 @@ static void udp_do_one(int lnr, const char *line,const char *prot)
if ((strlen(rem_addr) + strlen(buffer)) > 22)
rem_addr[22 - strlen(buffer)] = '\0';
strcat(rem_addr, ":");
- strcat(rem_addr, buffer);
+ strncat(rem_addr, buffer, sizeof(rem_addr)-strlen(rem_addr)-1);
timers[0] = '\0';
if (flag_opt)
@@ -1220,7 +1220,7 @@ static void raw_do_one(int lnr, const char *line,const char *prot)
if ((strlen(local_addr) + strlen(buffer)) > 22)
local_addr[22 - strlen(buffer)] = '\0';
strcat(local_addr, ":");
- strcat(local_addr, buffer);
+ strncat(local_addr, buffer, sizeof(local_addr)-strlen(local_addr)-1);
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(rem_port), "raw", flag_not & FLAG_NUM_PORT));
@@ -1229,7 +1229,7 @@ static void raw_do_one(int lnr, const char *line,const char *prot)
if ((strlen(rem_addr) + strlen(buffer)) > 22)
rem_addr[22 - strlen(buffer)] = '\0';
strcat(rem_addr, ":");
- strcat(rem_addr, buffer);
+ strncat(rem_addr, buffer, sizeof(rem_addr)-strlen(rem_addr)-1);
timers[0] = '\0';
if (flag_opt)
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/net-tools:master commit in: /
@ 2011-11-21 1:35 Mike Frysinger
2011-11-21 1:38 ` [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
0 siblings, 1 reply; 12+ messages in thread
From: Mike Frysinger @ 2011-11-21 1:35 UTC (permalink / raw
To: gentoo-commits
commit: c5e8dfb6877b0410e75fbe9f8a66dd9e226eda72
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 21 00:49:58 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Nov 21 00:49:58 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=c5e8dfb6
fix "format not a string literal" warnings
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
mii-tool.c | 2 +-
rarp.c | 2 +-
slattach.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/mii-tool.c b/mii-tool.c
index d812e8a..39d2f3f 100644
--- a/mii-tool.c
+++ b/mii-tool.c
@@ -271,7 +271,7 @@ int show_basic_mii(int sock, int phy_id)
if (opt_watch) {
if (opt_log) {
- syslog(LOG_INFO, buf);
+ syslog(LOG_INFO, "%s", buf);
} else {
char s[20];
time_t t = time(NULL);
diff --git a/rarp.c b/rarp.c
index 73f8731..2f34c87 100644
--- a/rarp.c
+++ b/rarp.c
@@ -226,7 +226,7 @@ int main(int argc, char **argv)
case 'h':
usage();
case 'V':
- fprintf(stderr, version_string);
+ fputs(version_string, stderr);
exit(E_VERSION);
break;
case 'v':
diff --git a/slattach.c b/slattach.c
index d2b6f3c..0f4ccd6 100644
--- a/slattach.c
+++ b/slattach.c
@@ -569,7 +569,7 @@ usage(void)
"[-c cmd] [-s speed] [-p protocol] tty | -\n"
" slattach -V | --version\n";
- fprintf(stderr, usage_msg);
+ fputs(usage_msg, stderr);
exit(1);
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/net-tools:gentoo commit in: /
2011-11-21 1:35 [gentoo-commits] proj/net-tools:master commit in: / Mike Frysinger
@ 2011-11-21 1:38 ` Mike Frysinger
0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2011-11-21 1:38 UTC (permalink / raw
To: gentoo-commits
commit: c5e8dfb6877b0410e75fbe9f8a66dd9e226eda72
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 21 00:49:58 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Nov 21 00:49:58 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=c5e8dfb6
fix "format not a string literal" warnings
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
mii-tool.c | 2 +-
rarp.c | 2 +-
slattach.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/mii-tool.c b/mii-tool.c
index d812e8a..39d2f3f 100644
--- a/mii-tool.c
+++ b/mii-tool.c
@@ -271,7 +271,7 @@ int show_basic_mii(int sock, int phy_id)
if (opt_watch) {
if (opt_log) {
- syslog(LOG_INFO, buf);
+ syslog(LOG_INFO, "%s", buf);
} else {
char s[20];
time_t t = time(NULL);
diff --git a/rarp.c b/rarp.c
index 73f8731..2f34c87 100644
--- a/rarp.c
+++ b/rarp.c
@@ -226,7 +226,7 @@ int main(int argc, char **argv)
case 'h':
usage();
case 'V':
- fprintf(stderr, version_string);
+ fputs(version_string, stderr);
exit(E_VERSION);
break;
case 'v':
diff --git a/slattach.c b/slattach.c
index d2b6f3c..0f4ccd6 100644
--- a/slattach.c
+++ b/slattach.c
@@ -569,7 +569,7 @@ usage(void)
"[-c cmd] [-s speed] [-p protocol] tty | -\n"
" slattach -V | --version\n";
- fprintf(stderr, usage_msg);
+ fputs(usage_msg, stderr);
exit(1);
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/net-tools:gentoo commit in: /
@ 2011-11-21 1:38 Mike Frysinger
0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2011-11-21 1:38 UTC (permalink / raw
To: gentoo-commits
commit: 9eba397314f86e231fa091e5203a80eccfacd6b8
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 21 00:51:23 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Nov 21 00:51:55 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=9eba3973
fix integer/pointer cast warnings
On 64bit systems where sizeof(void *) != sizeof(int), we get a warning
when trying to assign the return of atoi(). So insert a cast to avoid.
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
ifconfig.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ifconfig.c b/ifconfig.c
index 952e705..44cea40 100644
--- a/ifconfig.c
+++ b/ifconfig.c
@@ -497,7 +497,7 @@ int main(int argc, char **argv)
if (!strcmp(*spp, "keepalive")) {
if (*++spp == NULL)
usage();
- ifr.ifr_data = (caddr_t) atoi(*spp);
+ ifr.ifr_data = (caddr_t) (uintptr_t) atoi(*spp);
if (ioctl(skfd, SIOCSKEEPALIVE, &ifr) < 0) {
fprintf(stderr, "SIOCSKEEPALIVE: %s\n", strerror(errno));
goterr = 1;
@@ -511,7 +511,7 @@ int main(int argc, char **argv)
if (!strcmp(*spp, "outfill")) {
if (*++spp == NULL)
usage();
- ifr.ifr_data = (caddr_t) atoi(*spp);
+ ifr.ifr_data = (caddr_t) (uintptr_t) atoi(*spp);
if (ioctl(skfd, SIOCSOUTFILL, &ifr) < 0) {
fprintf(stderr, "SIOCSOUTFILL: %s\n", strerror(errno));
goterr = 1;
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/net-tools:gentoo commit in: /
2011-11-21 1:35 [gentoo-commits] proj/net-tools:master " Mike Frysinger
@ 2011-11-21 1:38 ` Mike Frysinger
0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2011-11-21 1:38 UTC (permalink / raw
To: gentoo-commits
commit: 9cd07a6fa5b7117008a716f774db884cecc55468
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 21 01:31:57 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Nov 21 01:31:57 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=9cd07a6f
netstat: unify duplicate addr pretty printing
The tcp/udp/raw protocols duplicate the logic for looking up addresses and
their ports, and then formatting them nicely. They also duplicate this for
local and remote addresses. They also encode a few assumptions about the
length of the strings they get back which can cause buffer over and under
flows.
Add a new helper called addr_do_one that unifies all of this duplicate
logic in one place, and handles any string size correctly.
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
netstat.c | 102 ++++++++++++++++++++++--------------------------------------
1 files changed, 38 insertions(+), 64 deletions(-)
diff --git a/netstat.c b/netstat.c
index 7b45fc8..07d3da3 100644
--- a/netstat.c
+++ b/netstat.c
@@ -870,11 +870,39 @@ static int sctp_info(void) {
return sctp_info_assocs();
}
+static void addr_do_one(char *buf, size_t buf_len, size_t short_len, struct aftype *ap,
+#if HAVE_AFINET6
+ struct sockaddr_in6 *addr,
+#else
+ struct sockaddr_in *addr,
+#endif
+ int port, const char *proto
+)
+{
+ const char *sport, *saddr;
+ size_t port_len, addr_len;
+
+ saddr = ap->sprint((struct sockaddr *)addr, flag_not & FLAG_NUM_HOST);
+ sport = get_sname(htons(port), proto, flag_not & FLAG_NUM_PORT);
+ addr_len = strlen(saddr);
+ port_len = strlen(sport);
+ if (!flag_wide && (addr_len + port_len > short_len)) {
+ /* Assume port name is short */
+ port_len = netmin(port_len, short_len - 4);
+ addr_len = short_len - port_len;
+ strncpy(buf, saddr, addr_len);
+ buf[addr_len] = '\0';
+ strcat(buf, ":");
+ strncat(buf, sport, port_len);
+ } else
+ snprintf(buf, buf_len, "%s:%s", saddr, sport);
+}
+
static void tcp_do_one(int lnr, const char *line, const char *prot)
{
unsigned long rxq, txq, time_len, retr, inode;
int num, local_port, rem_port, d, state, uid, timer_run, timeout;
- char rem_addr[128], local_addr[128], timers[64], buffer[1024], more[512];
+ char rem_addr[128], local_addr[128], timers[64], more[512];
struct aftype *ap;
#if HAVE_AFINET6
struct sockaddr_in6 localaddr, remaddr;
@@ -930,34 +958,11 @@ static void tcp_do_one(int lnr, const char *line, const char *prot)
((struct sockaddr *) &localaddr)->sa_family);
return;
}
- safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr,
- flag_not & FLAG_NUM_HOST), sizeof(local_addr));
- safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr, flag_not & FLAG_NUM_HOST),
- sizeof(rem_addr));
-
- snprintf(buffer, sizeof(buffer), "%s",
- get_sname(htons(local_port), "tcp",
- flag_not & FLAG_NUM_PORT));
-
- if (!flag_wide) {
- if ((strlen(local_addr) + strlen(buffer)) > 22)
- local_addr[22 - strlen(buffer)] = '\0';
- }
-
- strcat(local_addr, ":");
- strcat(local_addr, buffer);
- snprintf(buffer, sizeof(buffer), "%s",
- get_sname(htons(rem_port), "tcp", flag_not & FLAG_NUM_PORT));
- if (!flag_wide) {
- if ((strlen(rem_addr) + strlen(buffer)) > 22)
- rem_addr[22 - strlen(buffer)] = '\0';
- }
+ addr_do_one(local_addr, sizeof(local_addr), 22, ap, &localaddr, local_port, "tcp");
+ addr_do_one(rem_addr, sizeof(rem_addr), 22, ap, &remaddr, rem_port, "tcp");
- strcat(rem_addr, ":");
- strcat(rem_addr, buffer);
timers[0] = '\0';
-
if (flag_opt)
switch (timer_run) {
case 0:
@@ -984,6 +989,7 @@ static void tcp_do_one(int lnr, const char *line, const char *prot)
timer_run, (double) time_len / HZ, retr, timeout);
break;
}
+
printf("%-4s %6ld %6ld %-*s %-*s %-11s",
prot, rxq, txq, (int)netmax(23,strlen(local_addr)), local_addr, (int)netmax(23,strlen(rem_addr)), rem_addr, _(tcp_state[state]));
@@ -998,7 +1004,7 @@ static int tcp_info(void)
static void udp_do_one(int lnr, const char *line,const char *prot)
{
- char buffer[8192], local_addr[64], rem_addr[64];
+ char local_addr[64], rem_addr[64];
char *udp_state, timers[64], more[512];
int num, local_port, rem_port, d, state, timer_run, uid, timeout;
#if HAVE_AFINET6
@@ -1087,24 +1093,8 @@ static void udp_do_one(int lnr, const char *line,const char *prot)
if (flag_all || (notnull(remaddr) && !flag_lst) || (!notnull(remaddr) && flag_lst))
{
- safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr,
- flag_not & FLAG_NUM_HOST), sizeof(local_addr));
- snprintf(buffer, sizeof(buffer), "%s",
- get_sname(htons(local_port), "udp",
- flag_not & FLAG_NUM_PORT));
- if ((strlen(local_addr) + strlen(buffer)) > 22)
- local_addr[22 - strlen(buffer)] = '\0';
- strcat(local_addr, ":");
- strcat(local_addr, buffer);
-
- snprintf(buffer, sizeof(buffer), "%s",
- get_sname(htons(rem_port), "udp", flag_not & FLAG_NUM_PORT));
- safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr,
- flag_not & FLAG_NUM_HOST), sizeof(rem_addr));
- if ((strlen(rem_addr) + strlen(buffer)) > 22)
- rem_addr[22 - strlen(buffer)] = '\0';
- strcat(rem_addr, ":");
- strcat(rem_addr, buffer);
+ addr_do_one(local_addr, sizeof(local_addr), 22, ap, &localaddr, local_port, "udp");
+ addr_do_one(rem_addr, sizeof(rem_addr), 22, ap, &remaddr, rem_port, "udp");
timers[0] = '\0';
if (flag_opt)
@@ -1144,7 +1134,7 @@ static int udplite_info(void)
static void raw_do_one(int lnr, const char *line,const char *prot)
{
- char buffer[8192], local_addr[64], rem_addr[64];
+ char local_addr[64], rem_addr[64];
char timers[64], more[512];
int num, local_port, rem_port, d, state, timer_run, uid, timeout;
#if HAVE_AFINET6
@@ -1212,24 +1202,8 @@ static void raw_do_one(int lnr, const char *line,const char *prot)
if (flag_all || (notnull(remaddr) && !flag_lst) || (!notnull(remaddr) && flag_lst))
{
- snprintf(buffer, sizeof(buffer), "%s",
- get_sname(htons(local_port), "raw",
- flag_not & FLAG_NUM_PORT));
- safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr,
- flag_not & FLAG_NUM_HOST), sizeof(local_addr));
- if ((strlen(local_addr) + strlen(buffer)) > 22)
- local_addr[22 - strlen(buffer)] = '\0';
- strcat(local_addr, ":");
- strcat(local_addr, buffer);
-
- snprintf(buffer, sizeof(buffer), "%s",
- get_sname(htons(rem_port), "raw", flag_not & FLAG_NUM_PORT));
- safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr,
- flag_not & FLAG_NUM_HOST), sizeof(rem_addr));
- if ((strlen(rem_addr) + strlen(buffer)) > 22)
- rem_addr[22 - strlen(buffer)] = '\0';
- strcat(rem_addr, ":");
- strcat(rem_addr, buffer);
+ addr_do_one(local_addr, sizeof(local_addr), 22, ap, &localaddr, local_port, "raw");
+ addr_do_one(rem_addr, sizeof(rem_addr), 22, ap, &remaddr, rem_port, "raw");
timers[0] = '\0';
if (flag_opt)
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2011-11-21 1:39 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-21 1:35 [gentoo-commits] proj/net-tools:master commit in: / Mike Frysinger
2011-11-21 1:38 ` [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
-- strict thread matches above, loose matches on Subject: below --
2011-11-21 1:38 Mike Frysinger
2011-11-21 1:35 [gentoo-commits] proj/net-tools:master " Mike Frysinger
2011-11-21 1:38 ` [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
2011-08-20 4:57 Mike Frysinger
2011-08-20 4:57 [gentoo-commits] proj/net-tools:master " Mike Frysinger
2011-08-20 4:57 ` [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
2011-08-20 4:57 [gentoo-commits] proj/net-tools:master " Mike Frysinger
2011-08-20 4:57 ` [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
2011-04-09 13:58 [gentoo-commits] proj/net-tools:master " Mike Frysinger
2011-04-09 13:58 ` [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
2011-04-09 13:58 [gentoo-commits] proj/net-tools:master " Mike Frysinger
2011-04-09 13:58 ` [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
2011-04-09 13:58 [gentoo-commits] proj/net-tools:master " Mike Frysinger
2011-04-09 13:58 ` [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
2011-04-09 13:58 Mike Frysinger
2011-04-09 13:58 Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox