From owner-svn-src-head@freebsd.org Mon Mar 26 22:02:37 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 259E2F6F567; Mon, 26 Mar 2018 22:02:37 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7659776C96; Mon, 26 Mar 2018 22:02:36 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7155812DF3; Mon, 26 Mar 2018 22:02:36 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2QM2ae6067800; Mon, 26 Mar 2018 22:02:36 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2QM2aJh067799; Mon, 26 Mar 2018 22:02:36 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201803262202.w2QM2aJh067799@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Mon, 26 Mar 2018 22:02:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331595 - head/cddl/contrib/opensolaris/common/ctf X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/cddl/contrib/opensolaris/common/ctf X-SVN-Commit-Revision: 331595 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Mar 2018 22:02:37 -0000 Author: cem Date: Mon Mar 26 22:02:36 2018 New Revision: 331595 URL: https://svnweb.freebsd.org/changeset/base/331595 Log: libctf: Don't construct pointers to out of bounds array offsets Just attempting to do the pointer arithmetic is undefined behavior. No functional change intended. Reported by: Coverity Sponsored by: Dell EMC Isilon Modified: head/cddl/contrib/opensolaris/common/ctf/ctf_lookup.c Modified: head/cddl/contrib/opensolaris/common/ctf/ctf_lookup.c ============================================================================== --- head/cddl/contrib/opensolaris/common/ctf/ctf_lookup.c Mon Mar 26 21:57:44 2018 (r331594) +++ head/cddl/contrib/opensolaris/common/ctf/ctf_lookup.c Mon Mar 26 22:02:36 2018 (r331595) @@ -59,10 +59,12 @@ isqualifier(const char *s, size_t len) }; int h = s[len - 1] + (int)len - 105; - const struct qual *qp = &qhash[h]; + const struct qual *qp; - return (h >= 0 && h < sizeof (qhash) / sizeof (qhash[0]) && - len == qp->q_len && strncmp(qp->q_name, s, qp->q_len) == 0); + if (h < 0 || h >= sizeof (qhash) / sizeof (qhash[0])) + return (0); + qp = &qhash[h]; + return (len == qp->q_len && strncmp(qp->q_name, s, qp->q_len) == 0); } /*