1 --- net-tools-1.60/netstat.c.inode 2006-02-23 09:28:23.000000000 +0100
2 +++ net-tools-1.60/netstat.c 2006-02-23 09:33:57.000000000 +0100
5 static struct prg_node {
9 char name[PROGNAME_WIDTH];
10 char scon[SELINUX_WIDTH];
11 } *prg_hash[PRG_HASH_SIZE];
13 /* NOT working as of glibc-2.0.7: */
14 #undef DIRENT_HAVE_D_TYPE_WORKS
16 -static void prg_cache_add(int inode, char *name, char *scon)
17 +static void prg_cache_add(unsigned long inode, char *name, char *scon)
19 unsigned hi = PRG_HASHIT(inode);
20 struct prg_node **pnp,*pn;
25 -static void extract_type_1_socket_inode(const char lname[], long * inode_p) {
26 +static void extract_type_1_socket_inode(const char lname[], unsigned long * inode_p, int * status) {
28 /* If lname is of the form "socket:[12345]", extract the "12345"
29 - as *inode_p. Otherwise, return -1 as *inode_p.
30 + as *inode_p. Otherwise, return -1 as *status.
33 - if (strlen(lname) < PRG_SOCKET_PFXl+3) *inode_p = -1;
34 - else if (memcmp(lname, PRG_SOCKET_PFX, PRG_SOCKET_PFXl)) *inode_p = -1;
35 - else if (lname[strlen(lname)-1] != ']') *inode_p = -1;
37 + if (strlen(lname) < PRG_SOCKET_PFXl+3) *status = -1;
38 + else if (memcmp(lname, PRG_SOCKET_PFX, PRG_SOCKET_PFXl)) *status = -1;
39 + else if (lname[strlen(lname)-1] != ']') *status = -1;
41 char inode_str[strlen(lname + 1)]; /* e.g. "12345" */
42 const int inode_str_len = strlen(lname) - PRG_SOCKET_PFXl - 1;
45 strncpy(inode_str, lname+PRG_SOCKET_PFXl, inode_str_len);
46 inode_str[inode_str_len] = '\0';
47 - *inode_p = strtol(inode_str,&serr,0);
48 - if (!serr || *serr || *inode_p < 0 || *inode_p >= INT_MAX)
51 + *inode_p = strtoul(inode_str,&serr,0);
52 + if (!serr || *serr || errno)
59 -static void extract_type_2_socket_inode(const char lname[], long * inode_p) {
60 +static void extract_type_2_socket_inode(const char lname[], unsigned long * inode_p, int * status) {
62 /* If lname is of the form "[0000]:12345", extract the "12345"
63 - as *inode_p. Otherwise, return -1 as *inode_p.
64 + as *inode_p. Otherwise, return -1 as *status.
67 - if (strlen(lname) < PRG_SOCKET_PFX2l+1) *inode_p = -1;
68 - else if (memcmp(lname, PRG_SOCKET_PFX2, PRG_SOCKET_PFX2l)) *inode_p = -1;
69 + if (strlen(lname) < PRG_SOCKET_PFX2l+1) *status = -1;
70 + else if (memcmp(lname, PRG_SOCKET_PFX2, PRG_SOCKET_PFX2l)) *status = -1;
74 - *inode_p=strtol(lname + PRG_SOCKET_PFX2l,&serr,0);
75 - if (!serr || *serr || *inode_p < 0 || *inode_p >= INT_MAX)
78 + *inode_p=strtoul(lname + PRG_SOCKET_PFX2l,&serr,0);
79 + if (!serr || *serr || errno)
85 char line[LINE_MAX],eacces=0;
86 int procfdlen,fd,cmdllen,lnamelen;
87 char lname[30],cmdlbuf[512],finbuf[PROGNAME_WIDTH];
89 + unsigned long inode;
90 const char *cs,*cmdlp;
91 DIR *dirproc=NULL,*dirfd=NULL;
92 struct dirent *direproc,*direfd;
93 security_context_t scon=NULL;
96 if (prg_cache_loaded || !flag_prg) return;
99 lnamelen=readlink(line,lname,sizeof(lname)-1);
100 lname[lnamelen] = '\0'; /*make it a null-terminated string*/
102 - extract_type_1_socket_inode(lname, &inode);
103 + extract_type_1_socket_inode(lname, &inode, &status);
105 - if (inode < 0) extract_type_2_socket_inode(lname, &inode);
106 + if (status < 0) extract_type_2_socket_inode(lname, &inode, &status);
108 - if (inode < 0) continue;
109 + if (status < 0) continue;
112 if (procfdlen - PATH_FD_SUFFl + PATH_CMDLINEl >=
114 printf("%-10s ", pw->pw_name);
116 printf("%-10d ", uid);
117 - printf("%-10ld ",inode);
118 + printf("%-10lu ",inode);
121 printf("%-" PROGNAME_WIDTHs "s",prg_cache_get(inode));
126 - "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %ld %512s\n",
127 + "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %512s\n",
128 &d, local_addr, &local_port, rem_addr, &rem_port, &state,
129 &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);
131 @@ -1064,7 +1068,7 @@
135 - "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %ld %512s\n",
136 + "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %512s\n",
137 &d, local_addr, &local_port,
138 rem_addr, &rem_port, &state,
139 &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);
140 @@ -1206,7 +1210,7 @@
144 - "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %ld %512s\n",
145 + "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %512s\n",
146 &d, local_addr, &local_port, rem_addr, &rem_port, &state,
147 &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);
149 @@ -1320,9 +1324,9 @@
151 char path[MAXPATHLEN], ss_flags[32];
152 char *ss_proto, *ss_state, *ss_type;
153 - int num, state, type, inode;
154 + int num, state, type;
156 - unsigned long refcnt, proto, flags;
157 + unsigned long refcnt, proto, flags, inode;
160 if (strstr(line, "Inode"))
161 @@ -1330,14 +1334,14 @@
165 - num = sscanf(line, "%p: %lX %lX %lX %X %X %d %s",
166 + num = sscanf(line, "%p: %lX %lX %lX %X %X %lu %s",
167 &d, &refcnt, &proto, &flags, &type, &state, &inode, path);
169 fprintf(stderr, _("warning, got bogus unix line.\n"));
172 if (!(has & HAS_INODE))
173 - snprintf(path,sizeof(path),"%d",inode);
174 + snprintf(path,sizeof(path),"%lu",inode);
177 if ((state == SS_UNCONNECTED) && (flags & SO_ACCEPTCON)) {
178 @@ -1429,7 +1433,7 @@
179 printf("%-5s %-6ld %-11s %-10s %-13s ",
180 ss_proto, refcnt, ss_flags, ss_type, ss_state);
182 - printf("%-6d ",inode);
183 + printf("%-6lu ",inode);