Author: ngie
Date: Wed Jan  4 17:33:18 2017
New Revision: 311290
URL: https://svnweb.freebsd.org/changeset/base/311290

Log:
  Use strlcpy instead of strcpy when copying the bridge name to ifr.ifr_name
  to avoid buffer overflows
  
  MFC after:    1 week
  Reported by:  Coverity
  CID:          1006735, 1006737, 1006738

Modified:
  head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c

Modified: head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c
==============================================================================
--- head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c       Wed Jan  4 
16:36:51 2017        (r311289)
+++ head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c       Wed Jan  4 
17:33:18 2017        (r311290)
@@ -485,7 +485,7 @@ bridge_set_if_up(const char* b_name, int
        struct ifreq ifr;
 
        bzero(&ifr, sizeof(ifr));
-       strcpy(ifr.ifr_name, b_name);
+       strlcpy(ifr.ifr_name, b_name, sizeof(ifr.ifr_name));
        if (ioctl(sock, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
                syslog(LOG_ERR, "set bridge up: ioctl(SIOCGIFFLAGS) "
                    "failed: %s", strerror(errno));
@@ -516,7 +516,7 @@ bridge_create(const char *b_name)
        struct ifreq ifr;
 
        bzero(&ifr, sizeof(ifr));
-       strcpy(ifr.ifr_name, b_name);
+       strlcpy(ifr.ifr_name, b_name, sizeof(ifr.ifr_name));
 
        if (ioctl(sock, SIOCIFCREATE, &ifr) < 0) {
                syslog(LOG_ERR, "create bridge: ioctl(SIOCIFCREATE) "
@@ -549,7 +549,7 @@ bridge_destroy(const char *b_name)
        struct ifreq ifr;
 
        bzero(&ifr, sizeof(ifr));
-       strcpy(ifr.ifr_name, b_name);
+       strlcpy(ifr.ifr_name, b_name, sizeof(ifr.ifr_name));
 
        if (ioctl(sock, SIOCIFDESTROY, &ifr) < 0) {
                syslog(LOG_ERR, "destroy bridge: ioctl(SIOCIFDESTROY) "
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to