Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Jan 2017 07:55:17 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r311378 - head/contrib/bsnmp/snmpd
Message-ID:  <201701050755.v057tHLE061136@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701050755.v057tHLE061136>