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);
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to