svn commit: r260394 - in head/sys: dev/firewire net
Alexander V. Chernikov
melifaro at FreeBSD.org
Tue Jan 7 15:59:34 UTC 2014
Author: melifaro
Date: Tue Jan 7 15:59:33 2014
New Revision: 260394
URL: http://svnweb.freebsd.org/changeset/base/260394
Log:
Teach every SIOCGIFSTATUS provider to fill in ifs->ascii anyway.
Remove old bits of data concat for 'ascii' field.
Remove special SIOCGIFSTATUS handling from if.c (which Coverity yells at).
Reported by: Coverity
Coverity CID: 1147174
MFC after: 2 weeks
Modified:
head/sys/dev/firewire/if_fwe.c
head/sys/net/if.c
head/sys/net/if_tap.c
head/sys/net/if_tun.c
Modified: head/sys/dev/firewire/if_fwe.c
==============================================================================
--- head/sys/dev/firewire/if_fwe.c Tue Jan 7 14:03:42 2014 (r260393)
+++ head/sys/dev/firewire/if_fwe.c Tue Jan 7 15:59:33 2014 (r260394)
@@ -403,7 +403,7 @@ fwe_ioctl(struct ifnet *ifp, u_long cmd,
{
struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe;
struct ifstat *ifs = NULL;
- int s, error, len;
+ int s, error;
switch (cmd) {
case SIOCSIFFLAGS:
@@ -434,12 +434,8 @@ fwe_ioctl(struct ifnet *ifp, u_long cmd,
case SIOCGIFSTATUS:
s = splimp();
ifs = (struct ifstat *)data;
- len = strlen(ifs->ascii);
- if (len < sizeof(ifs->ascii))
- snprintf(ifs->ascii + len,
- sizeof(ifs->ascii) - len,
- "\tch %d dma %d\n",
- fwe->stream_ch, fwe->dma_ch);
+ snprintf(ifs->ascii, sizeof(ifs->ascii),
+ "\tch %d dma %d\n", fwe->stream_ch, fwe->dma_ch);
splx(s);
break;
case SIOCSIFCAP:
Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c Tue Jan 7 14:03:42 2014 (r260393)
+++ head/sys/net/if.c Tue Jan 7 15:59:33 2014 (r260394)
@@ -2088,7 +2088,6 @@ static int
ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
{
struct ifreq *ifr;
- struct ifstat *ifs;
int error = 0;
int new_flags, temp_flags;
size_t namelen, onamelen;
@@ -2425,9 +2424,6 @@ ifhwioctl(u_long cmd, struct ifnet *ifp,
break;
case SIOCGIFSTATUS:
- ifs = (struct ifstat *)data;
- ifs->ascii[0] = '\0';
-
case SIOCGIFPSRCADDR:
case SIOCGIFPDSTADDR:
case SIOCGIFMEDIA:
Modified: head/sys/net/if_tap.c
==============================================================================
--- head/sys/net/if_tap.c Tue Jan 7 14:03:42 2014 (r260393)
+++ head/sys/net/if_tap.c Tue Jan 7 15:59:33 2014 (r260394)
@@ -636,12 +636,12 @@ tapifioctl(struct ifnet *ifp, u_long cmd
case SIOCGIFSTATUS:
ifs = (struct ifstat *)data;
- dummy = strlen(ifs->ascii);
mtx_lock(&tp->tap_mtx);
- if (tp->tap_pid != 0 && dummy < sizeof(ifs->ascii))
- snprintf(ifs->ascii + dummy,
- sizeof(ifs->ascii) - dummy,
+ if (tp->tap_pid != 0)
+ snprintf(ifs->ascii, sizeof(ifs->ascii),
"\tOpened by PID %d\n", tp->tap_pid);
+ else
+ ifs->ascii[0] = '\0';
mtx_unlock(&tp->tap_mtx);
break;
Modified: head/sys/net/if_tun.c
==============================================================================
--- head/sys/net/if_tun.c Tue Jan 7 14:03:42 2014 (r260393)
+++ head/sys/net/if_tun.c Tue Jan 7 15:59:33 2014 (r260394)
@@ -546,8 +546,10 @@ tunifioctl(struct ifnet *ifp, u_long cmd
ifs = (struct ifstat *)data;
mtx_lock(&tp->tun_mtx);
if (tp->tun_pid)
- sprintf(ifs->ascii + strlen(ifs->ascii),
+ snprintf(ifs->ascii, sizeof(ifs->ascii),
"\tOpened by PID %d\n", tp->tun_pid);
+ else
+ ifs->ascii[0] = '\0';
mtx_unlock(&tp->tun_mtx);
break;
case SIOCSIFADDR:
More information about the svn-src-head
mailing list