svn commit: r295242 - user/ngie/bsnmp_cleanup/usr.sbin/bsnmpd/tools/libbsnmptools
Garrett Cooper
ngie at FreeBSD.org
Thu Feb 4 08:42:35 UTC 2016
Author: ngie
Date: Thu Feb 4 08:42:33 2016
New Revision: 295242
URL: https://svnweb.freebsd.org/changeset/base/295242
Log:
- Fix some broken logic committed in r295191. I should have used MIN, not MAX,
when capping the buffer length with strlcpy in snmp_oid2asn_oid(..) [*].
- Make `i` in to size_t to get the types of i and sizeof in sync and fix a
-Wsign-compare warning.
Reported by: bde [*]
Modified:
user/ngie/bsnmp_cleanup/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
Modified: user/ngie/bsnmp_cleanup/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
==============================================================================
--- user/ngie/bsnmp_cleanup/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Thu Feb 4 08:38:13 2016 (r295241)
+++ user/ngie/bsnmp_cleanup/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Thu Feb 4 08:42:33 2016 (r295242)
@@ -1060,8 +1060,8 @@ static char *
snmp_oid2asn_oid(struct snmp_toolinfo *snmptoolctx, char *str,
struct asn_oid *oid)
{
- int32_t i;
char string[MAXSTR], *endptr;
+ size_t i;
struct snmp_object obj;
for (i = 0; i < MAXSTR; i++)
@@ -1076,7 +1076,7 @@ snmp_oid2asn_oid(struct snmp_toolinfo *s
if (snmp_suboid_append(oid, (asn_subid_t) obj.val.var.len) < 0)
return (NULL);
} else {
- strlcpy(string, str, MAX(i + 1, sizeof(string)));
+ strlcpy(string, str, MIN(i + 1, nitems(string)));
if (snmp_lookup_enumoid(snmptoolctx, &obj, string) < 0) {
warnx("Unknown string - %s",string);
return (NULL);
More information about the svn-src-user
mailing list