Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 May 2016 00:01:23 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r299802 - head/usr.sbin/bsnmpd/tools/libbsnmptools
Message-ID:  <201605150001.u4F01NqL095152@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sun May 15 00:01:23 2016
New Revision: 299802
URL: https://svnweb.freebsd.org/changeset/base/299802

Log:
  Fix up both r299764 and r299770
  
  nitems was wrong too, as it was being tested against a pointer instead of a buffer on
  the stack.
  
  Since the old code was just doing malloc, then strlcpy'ing the contents of the source
  buffer into the destination buffer, replace it all with a call to strdup..
  
  Reported by: bde
  MFC after: 1 week
  X-MFC with: r299764, r299770
  Supersized Duncecap to: ngie
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c

Modified: head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
==============================================================================
--- head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c	Sat May 14 23:50:44 2016	(r299801)
+++ head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c	Sun May 15 00:01:23 2016	(r299802)
@@ -251,7 +251,7 @@ add_filename(struct snmp_toolinfo *snmpt
 			return (0);
 	}
 
-	if ((fstring = malloc(strlen(filename) + 1)) == NULL) {
+	if ((fstring = strdup(filename)) == NULL) {
 		warnx("malloc() failed - %s", strerror(errno));
 		return (-1);
 	}
@@ -264,7 +264,6 @@ add_filename(struct snmp_toolinfo *snmpt
 
 	if (cut != NULL)
 		asn_append_oid(&(entry->cut), cut);
-	strlcpy(fstring, filename, nitems(fstring));
 	entry->name = fstring;
 	entry->done = done;
 	SLIST_INSERT_HEAD(&snmptoolctx->filelist, entry, link);



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