Author: ngie
Date: Thu Jan  5 07:55:17 2017
New Revision: 311378
URL: https://svnweb.freebsd.org/changeset/base/311378

Log:
  lm_load: fix string copying issues
  
  - Ensure `section` doesn't overrun section by using strlcpy instead of
    strcpy [*].
  - Use strdup instead of malloc + strcpy (this wasn't flagged by Coverity,
    but is an opportunistic change).
  
  MFC after:    1 week
  Reported by:  Coverity
  CID:          1006826 [*]

Modified:
  head/contrib/bsnmp/snmpd/main.c

Modified: head/contrib/bsnmp/snmpd/main.c
==============================================================================
--- head/contrib/bsnmp/snmpd/main.c     Thu Jan  5 07:46:57 2017        
(r311377)
+++ head/contrib/bsnmp/snmpd/main.c     Thu Jan  5 07:55:17 2017        
(r311378)
@@ -2324,13 +2324,12 @@ lm_load(const char *path, const char *se
        }
        m->handle = NULL;
        m->flags = 0;
-       strcpy(m->section, section);
+       strlcpy(m->section, section, sizeof(m->section));
 
-       if ((m->path = malloc(strlen(path) + 1)) == NULL) {
+       if ((m->path = strdup(path)) == NULL) {
                syslog(LOG_ERR, "lm_load: %m");
                goto err;
        }
-       strcpy(m->path, path);
 
        /*
         * Make index
_______________________________________________
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