svn commit: r301690 - stable/9/usr.sbin/bsnmpd/tools/libbsnmptools

Garrett Cooper ngie at FreeBSD.org
Wed Jun 8 19:31:13 UTC 2016


Author: ngie
Date: Wed Jun  8 19:31:12 2016
New Revision: 301690
URL: https://svnweb.freebsd.org/changeset/base/301690

Log:
  MFstable/10 r301655:
  
  MFC r299766:
  
  Fix logically dead code pointed out by clang/Coverity
  
  parse_context, parse_user_security: test for validity of results from
  parse_ascii(..) with by casting to int32_t and comparing to -1; comparing
  unsigned types to negative values will always be false.
  
  CID: 1011432, 1011433

Modified:
  stable/9/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/usr.sbin/   (props changed)
  stable/9/usr.sbin/bsnmpd/   (props changed)

Modified: stable/9/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
==============================================================================
--- stable/9/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c	Wed Jun  8 19:24:48 2016	(r301689)
+++ stable/9/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c	Wed Jun  8 19:31:12 2016	(r301690)
@@ -614,8 +614,8 @@ parse_context(struct snmp_toolinfo *snmp
 				warnx("Suboption 'context-engine' - no argument");
 				return (-1);
 			}
-			if ((snmp_client.clen = parse_ascii(val,
-			    snmp_client.cengine, SNMP_ENGINE_ID_SIZ)) < 0) {
+			if ((int32_t)(snmp_client.clen = parse_ascii(val,
+			    snmp_client.cengine, SNMP_ENGINE_ID_SIZ)) == -1) {
 				warnx("Bad EngineID - %s", val);
 				return (-1);
 			}
@@ -653,7 +653,7 @@ parse_user_security(struct snmp_toolinfo
 			}
 			snmp_client.engine.engine_len = parse_ascii(val, 
 			    snmp_client.engine.engine_id, SNMP_ENGINE_ID_SIZ);
-			if (snmp_client.engine.engine_len < 0) {
+			if ((int32_t)snmp_client.engine.engine_len == -1) {
 				warnx("Bad EngineID - %s", val);
 				return (-1);
 			}


More information about the svn-src-stable-9 mailing list