diff options
author | 2011-04-09 13:52:05 +0000 | |
---|---|---|
committer | 2011-04-09 13:52:05 +0000 | |
commit | 74b2b5487338d65c468f76a7530c8c38692b56a1 (patch) | |
tree | afae7dc3e968b9f064d250bc5e4cbd51262e5543 | |
parent | hostname: fix FQDN handling with AAAA records (diff) | |
download | net-tools-74b2b5487338d65c468f76a7530c8c38692b56a1.tar.gz net-tools-74b2b5487338d65c468f76a7530c8c38692b56a1.tar.bz2 net-tools-74b2b5487338d65c468f76a7530c8c38692b56a1.zip |
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
-rw-r--r-- | netstat.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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); |