Commit 74b2b548 authored by Mike Frysinger's avatar Mike Frysinger

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
parent 80224366
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment