From nobody Fri Feb 02 18:53:21 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TRQ014kd0z59GmV; Fri, 2 Feb 2024 18:53:21 +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 4TRQ014Chtz4k5T; Fri, 2 Feb 2024 18:53:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706900001; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VXDRLIMWXrDGazfEZko9EPAsqQfzlMO97LjCzl8TVa0=; b=DLpJyr2gvPIY4RcuY1X4ufjfyq46DTi0jVjrCsXvX7J/vbjUbtEhrON3aRdvCK0eXsHX0W rdHHiKMHpt7WyrV2S9TNfQs8S8r/Xltj9+wHVzvDp6oFE9q8526eVtxQ9RyFQmFw2xkJec sjbeLmoIve89myWDiusCXElcDnqPiIo79UMSxfKrsO9xHyNrhs7ytKxL7Y+g3A3JQ8DIAK 1ZEvQAjjatFH4WE3a9PHGEp1PEjpONGUhwB+1zyceEKhoqICHLdT9y0YzWu3Surgcm3WXp DfWY1+rAPn337aGIOUVIxU8hT7MbsIiyvFfLQtMIK3/YKN9s++2VUMrE28zt9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706900001; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VXDRLIMWXrDGazfEZko9EPAsqQfzlMO97LjCzl8TVa0=; b=ZnJjisvDLwFqiMcXHggMMTSFGQuyh6naGAbA3Ry5DE5JMIrlGvyjHxFNBpIAkwZ+9TCjOb dCRGhOXK4kSGojJGShT+UsBfkaG4KO3w/nNTF/XO9GuRehWym1HpL5uJZql8dwoY7wl5jy WKYRJOPTUUNKMgGVFWJRSpaW5Ih7Chi2uNzklp+SHt0+CzlQKWzMwCrlwxeli8A2MzZj0O 40iHKoItRaVOI6BcNvcAaDhFdiqDDkJMFVi3tHFI7vGRK2iTCVFY4c6yojANoSQGEsG/3L 1Z9vepYNe6NBU5ztF26KbYeVlUfEgo4ZJas0sFs2NMtdjrTvqfgMqO8hSZtTCg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706900001; a=rsa-sha256; cv=none; b=oGMCONpeJS80s1l0QPHXMvUQ03aa8oF+eQ2BoZ18qFIyoyfVu9r1gCu5UTRt4q0HU6jkTW ifScYcr5mvcoPgQQY2z3cGGLovuRIfh7y18S+ob6UjjJFwuI4heZK3wNm4h5igrkDlY5To rkl+YhbWEZjn1ONSWoTux0Sh69IJKmynbSTE/a4trXcCvuacUJ1vTNrr1AytFc+EVzO2Fi ulSo9+TLHmScBjKwZneysrPBrxerTAc3fMXexm2TASGowsjPljSHeN+1PC9+jyOA5Cs1Ub IBU4EUNyRo22wS88JhuS5Z9YhNBYgn0MzKt/ZA7cMECwCBICpMu4kYrgcv6iVA== 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 4TRQ013GLKzhkl; Fri, 2 Feb 2024 18:53:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 412IrLLX036254; Fri, 2 Feb 2024 18:53:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 412IrLw7036251; Fri, 2 Feb 2024 18:53:21 GMT (envelope-from git) Date: Fri, 2 Feb 2024 18:53:21 GMT Message-Id: <202402021853.412IrLw7036251@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 619f455b8fc9 - main - regex: fix freeing g->charjump in low memory condition List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 619f455b8fc9d05b50822387d3203f74c86fcb5c Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=619f455b8fc9d05b50822387d3203f74c86fcb5c commit 619f455b8fc9d05b50822387d3203f74c86fcb5c Author: Corinna Vinschen AuthorDate: 2024-02-02 18:30:39 +0000 Commit: Warner Losh CommitDate: 2024-02-02 18:51:54 +0000 regex: fix freeing g->charjump in low memory condition computejumps() moves g->charjump to a position relativ to the value of CHAR_MIN. As such, g->charjump doesn't necessarily point to the address actually allocated. While regfree() takes that into account, the low memory handling in regcomp_internal() doesn't. Fix that by free'ing the actually allocated address, as in regfree(). MFC After: 2 weeks Reviewed by: imp,jrtc27 Pull Request: https://github.com/freebsd/freebsd-src/pull/692 --- lib/libc/regex/regcomp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index 89b96b00fefb..7481d3ecf240 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -321,7 +321,7 @@ regcomp_internal(regex_t * __restrict preg, computejumps(p, g); computematchjumps(p, g); if(g->matchjump == NULL && g->charjump != NULL) { - free(g->charjump); + free(&g->charjump[CHAR_MIN]); g->charjump = NULL; } }