Author: ngie
Date: Sat Dec 31 12:03:25 2016
New Revision: 310952
URL: https://svnweb.freebsd.org/changeset/base/310952

Log:
  MIB-II: use strlcpy instead of strcpy when copying {descr,name}
  
  This is of course to avoid buffer overruns
  
  The remaining strcpy instance in the module needs to be audited for
  correctness
  
  MFC after:    1 week
  Reported by:  Coverity
  CID:          1006827, 1006828

Modified:
  head/contrib/bsnmp/snmp_mibII/mibII.c

Modified: head/contrib/bsnmp/snmp_mibII/mibII.c
==============================================================================
--- head/contrib/bsnmp/snmp_mibII/mibII.c       Sat Dec 31 11:57:37 2016        
(r310951)
+++ head/contrib/bsnmp/snmp_mibII/mibII.c       Sat Dec 31 12:03:25 2016        
(r310952)
@@ -204,7 +204,7 @@ mib_if_set_dyn(const char *name)
                        return;
        if ((d = malloc(sizeof(*d))) == NULL)
                err(1, NULL);
-       strcpy(d->name, name);
+       strlcpy(d->name, name, sizeof(d->name));
        SLIST_INSERT_HEAD(&mibdynif_list, d, link);
 }
 
@@ -774,8 +774,8 @@ mibif_create(u_int sysindex, const char 
        memset(ifp->private, 0, sizeof(struct mibif_private));
 
        ifp->sysindex = sysindex;
-       strcpy(ifp->name, name);
-       strcpy(ifp->descr, name);
+       strlcpy(ifp->name, name, sizeof(ifp->name));
+       strlcpy(ifp->descr, name, sizeof(ifp->descr));
        ifp->spec_oid = oid_zeroDotZero;
 
        map = NULL;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to