svn commit: r299811 - head/usr.sbin/bsnmpd/tools/libbsnmptools
Garrett Cooper
ngie at FreeBSD.org
Sun May 15 00:25:37 UTC 2016
Author: ngie
Date: Sun May 15 00:25:36 2016
New Revision: 299811
URL: https://svnweb.freebsd.org/changeset/base/299811
Log:
Use strdup instead of malloc + strlcpy
Fix error messages on failure for calloc/strdup
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
Modified:
head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c
Modified: head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c
==============================================================================
--- head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c Sun May 15 00:24:21 2016 (r299810)
+++ head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c Sun May 15 00:25:36 2016 (r299811)
@@ -763,17 +763,16 @@ snmp_import_object(struct snmp_toolinfo
return (-1);
if ((oid2str = calloc(1, sizeof(struct snmp_oid2str))) == NULL) {
- syslog(LOG_ERR, "malloc() failed: %s", strerror(errno));
+ syslog(LOG_ERR, "calloc() failed: %s", strerror(errno));
return (-1);
}
- if ((string = malloc(strlen(nexttok) + 1)) == NULL) {
- syslog(LOG_ERR, "malloc() failed: %s", strerror(errno));
+ if ((string = strdup(nexttok)) == NULL) {
+ syslog(LOG_ERR, "strdup() failed: %s", strerror(errno));
free(oid2str);
return (-1);
}
- strlcpy(string, nexttok, nitems(string));
oid2str->string = string;
oid2str->strlen = strlen(nexttok);
More information about the svn-src-head
mailing list