From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 19:41:41 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 55244567803; Wed, 24 Feb 2021 19:41:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dm5s120nfz4XWv; Wed, 24 Feb 2021 19:41:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 37D1A1F57; Wed, 24 Feb 2021 19:41:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11OJffbP082695; Wed, 24 Feb 2021 19:41:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OJffnr082694; Wed, 24 Feb 2021 19:41:41 GMT (envelope-from git) Date: Wed, 24 Feb 2021 19:41:41 GMT Message-Id: <202102241941.11OJffnr082694@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 64809c763b0c - stable/12 - Fix possibly unitialized variables in __cxa_demangle_gnu3() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 64809c763b0c73fe488b61601670067056b07780 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Feb 2021 19:41:41 -0000 The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=64809c763b0c73fe488b61601670067056b07780 commit 64809c763b0c73fe488b61601670067056b07780 Author: Dimitry Andric AuthorDate: 2021-02-22 20:01:09 +0000 Commit: Dimitry Andric CommitDate: 2021-02-24 19:39:57 +0000 Fix possibly unitialized variables in __cxa_demangle_gnu3() After 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 where I imported a more recent libcxxrt snapshot, the variables 'rtn' and 'has_ret' could in some cases be used while still uninitialized. Most obviously this would lead to a jemalloc complaint about a bad free(), aborting the program. Fix this by initializing a bunch variables in their declarations. This change has also been sent upstream, with some additional changes to be used in their testing framework. PR: 253226 (cherry picked from commit d149877758f162f0c777e7760164bf2c1f7a1bc1) --- contrib/libcxxrt/libelftc_dem_gnu3.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/contrib/libcxxrt/libelftc_dem_gnu3.c b/contrib/libcxxrt/libelftc_dem_gnu3.c index 6e88f7b4bb4c..93e1c41fa034 100644 --- a/contrib/libcxxrt/libelftc_dem_gnu3.c +++ b/contrib/libcxxrt/libelftc_dem_gnu3.c @@ -538,8 +538,8 @@ __cxa_demangle_gnu3(const char *org) struct type_delimit td; ssize_t org_len; unsigned int limit; - char *rtn; - bool has_ret, more_type; + char *rtn = NULL; + bool has_ret = false, more_type = false; if (org == NULL) return (NULL); @@ -562,13 +562,9 @@ __cxa_demangle_gnu3(const char *org) return (rtn); } - if (!cpp_demangle_data_init(&ddata, org + 2)) return (NULL); - rtn = NULL; - has_ret = more_type = false; - if (!cpp_demangle_read_encoding(&ddata)) goto clean;