From b525fce336667f88a6a3d25089de1964d25f65cb Mon Sep 17 00:00:00 2001 From: ngie Date: Sun, 15 May 2016 00:01:23 +0000 Subject: 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 --- usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'usr.sbin/bsnmpd') 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); -- cgit v1.1