summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsnmpd
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2016-05-15 00:01:23 +0000
committerngie <ngie@FreeBSD.org>2016-05-15 00:01:23 +0000
commitb525fce336667f88a6a3d25089de1964d25f65cb (patch)
tree0a7989545f350ab47e4e9da4de3eac67ade1c2e8 /usr.sbin/bsnmpd
parent968a458f039a54c9a46966ccbc693f7a7ce70e1f (diff)
downloadFreeBSD-src-b525fce336667f88a6a3d25089de1964d25f65cb.zip
FreeBSD-src-b525fce336667f88a6a3d25089de1964d25f65cb.tar.gz
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
Diffstat (limited to 'usr.sbin/bsnmpd')
-rw-r--r--usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
index ed81e73..a7da86a 100644
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
@@ -251,7 +251,7 @@ add_filename(struct snmp_toolinfo *snmptoolctx, const char *filename,
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 *snmptoolctx, const char *filename,
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);
OpenPOWER on IntegriCloud