Date: Wed, 4 May 2016 00:14:50 +0000 (UTC) From: Garrett Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r299016 - stable/10/usr.sbin/bsnmpd/tools/libbsnmptools Message-ID: <201605040014.u440Eokb044340@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Wed May 4 00:14:50 2016 New Revision: 299016 URL: https://svnweb.freebsd.org/changeset/base/299016 Log: MFC r298451,r298452,r298507,r298750: r298451: Don't use `entry` after free in the "already in lists" case Return with 0 as it isn't an error. CID: 1006085 Obtained from: Isilon OneFS (part of r493633) r298452: Don't try to free `string` (stack allocated char[]) Fix minor style with warnx call while in the neighborhood CID: 1009683 r298507: Fix looking for "UTC" at start of ptr by using strnmp instead of improperly unrolled equivalent CID: 1347118 r298750: Use a better idiom for finding UTC prefixed timezones Instead of copy-pasting the string literal for "UTC" 3 times and using strlen, use a static char[3] buffer and sizeof(..). Modified: stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c Tue May 3 23:56:52 2016 (r299015) +++ stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c Wed May 4 00:14:50 2016 (r299016) @@ -693,6 +693,7 @@ snmp_import_table(struct snmp_toolinfo * /* Same entry already present in lists. */ free(entry->string); free(entry); + return (0); } (void) snmp_import_update_table(ENTRY_INDEX, entry); Modified: stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Tue May 3 23:56:52 2016 (r299015) +++ stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Wed May 4 00:14:50 2016 (r299016) @@ -338,8 +338,9 @@ static char * snmp_date2asn_oid(char *str, struct asn_oid *oid) { char *endptr, *ptr; - uint32_t v; + static const char UTC[3] = "UTC"; int32_t saved_errno; + uint32_t v; if (snmp_suboid_append(oid, (asn_subid_t) SNMP_DATETIME_OCTETS) < 0) return (NULL); @@ -440,8 +441,8 @@ snmp_date2asn_oid(char *str, struct asn_ /* 'UTC' - optional */ ptr = endptr + 1; - if (*ptr == 'U' && *(ptr + 1) == 'T' && *(ptr + 1) == 'C') - ptr += 3; + if (strncmp(ptr, UTC, sizeof(UTC)) == 0) + ptr += sizeof(UTC); /* '+/-' */ if (*ptr == '-' || *ptr == '+') { Modified: stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Tue May 3 23:56:52 2016 (r299015) +++ stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Wed May 4 00:14:50 2016 (r299016) @@ -1079,10 +1079,9 @@ snmp_oid2asn_oid(struct snmp_toolinfo *s strlcpy(string, str, i + 1); string[i] = '\0'; if (snmp_lookup_enumoid(snmptoolctx, &obj, string) < 0) { - warnx("Unknown string - %s",string); + warnx("Unknown string - %s", string); return (NULL); } - free(string); } asn_append_oid(oid, &(obj.val.var));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605040014.u440Eokb044340>