Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Jun 2016 17:30:29 +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: r301655 - stable/10/usr.sbin/bsnmpd/tools/libbsnmptools
Message-ID:  <201606081730.u58HUTXc029363@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Wed Jun  8 17:30:29 2016
New Revision: 301655
URL: https://svnweb.freebsd.org/changeset/base/301655

Log:
  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/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
==============================================================================
--- stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c	Wed Jun  8 17:29:07 2016	(r301654)
+++ stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c	Wed Jun  8 17:30:29 2016	(r301655)
@@ -615,8 +615,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);
 			}
@@ -654,7 +654,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);
 			}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606081730.u58HUTXc029363>