From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68D84280CD5 for ; Wed, 29 Jul 2026 00:41:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785285699; cv=none; b=ZqyXluA9TTgrFFmuHmvwUVouJCblP9krskbVGyIJwLXowAzKo0LheUfsxELqK+zLnf9UsBHIXMG5FG+lGSGwRf3Hj1wFwuTSt7eaZShQz2kwwhXvm4b3wn2hR9oau5u6Sd0T5IVDJfj4IRyTEPeEXnxK83Q6yo3iQAxw7vN9mO4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785285699; c=relaxed/simple; bh=x5hZlMTKAA85q/Vir9zg+7WTQZznWUfHAgnRcf/rMA4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=pkm4cBKWRtOFkd9euuwOVixkjzHEHxH8c0jdHajKx/0sZt//eQK3MabDDqGm5FCJqfTzlyXR/0TP3MYtGWbyQiycCbnjY1ZsfS6J5mllqaTz8GUss7lNik0eSHf92MYrarMfiESn2y85iTpPHWHu+W9IqyYQD/wV/MlQsWHIE7Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=vTwcYWQ1; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=c0e+LnYu; arc=none smtp.client-ip=103.168.172.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="vTwcYWQ1"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="c0e+LnYu" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id 56BDB140015A; Tue, 28 Jul 2026 20:41:36 -0400 (EDT) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-02.internal (MEProxy); Tue, 28 Jul 2026 20:41:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1785285696; x=1785372096; bh=U+D+t0amYh 1Rf40wom2LQB2gQBif/uw9b6lHSOUs+BI=; b=vTwcYWQ1m/c3DS3jJxvGtnuFKy A+/ED8TmymVjdmXqJ0GNvMmDdbeSVU6LJTa/BBOdFu7pQo2Pgk28j9tf2ddMSv6Q VHvFze/yBdQHBKYw190Re1AW/R36t3UG2HrlNJdW1kw8ep+jQce7+EqYy/NrnCEt A2KdnV12Sapw1Ss2+1DqR4f9968Mhhdw8eTdHU2lZUusbvCaLm+NCD9QswaxA4FR nd2p5zBHH5yAUH8X5wb+c85aZRO4gTxuPmII7mbz6fBit+bnaUfRwzixTcnCqDXQ m+vg+fxdRU4FY60MG0jQgM7PgW1yyxop2NoHvhUETnzID0DaFNQuQwuh5T3A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1785285696; x=1785372096; bh=U+D+t0amYh1R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E9G49Y0+vwiPTJJdt+w X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 28 Jul 2026 20:41:35 -0400 (EDT) From: Junio C Hamano To: Chungmin Lee Cc: git@vger.kernel.org Subject: Re: [PATCH v2] regexec: work around macOS TRE leak on invalid UTF-8 In-Reply-To: <20260728052538.12429-1-chungmin@chungminlee.com> (Chungmin Lee's message of "Mon, 27 Jul 2026 22:25:38 -0700") References: <20260722053127.37244-1-chungmin@chungminlee.com> <20260728052538.12429-1-chungmin@chungminlee.com> Date: Tue, 28 Jul 2026 17:41:34 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Chungmin Lee writes: > diff --git a/Makefile b/Makefile > index 1cec251..81075c3 100644 > --- a/Makefile > +++ b/Makefile > @@ -2264,6 +2264,10 @@ ifdef USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS > COMPAT_CFLAGS += -DUSE_ENHANCED_BASIC_REGULAR_EXPRESSIONS > COMPAT_OBJS += compat/regcomp_enhanced.o > endif > +ifdef DARWIN_REGEXEC > + COMPAT_OBJS += compat/darwin/regexec.o > + BASIC_CFLAGS += -DDARWIN_REGEXEC > +endif > endif > ifdef NATIVE_CRLF > BASIC_CFLAGS += -DNATIVE_CRLF > diff --git a/compat/darwin.h b/compat/darwin.h > new file mode 100644 > index 0000000..6fbdc34 > --- /dev/null > +++ b/compat/darwin.h > @@ -0,0 +1,8 @@ > +#ifndef COMPAT_DARWIN_H > +#define COMPAT_DARWIN_H > + > +int darwin_regexec_buf(const regex_t *preg, const char *buf, size_t size, > + size_t nmatch, regmatch_t pmatch[], int eflags); > +#define regexec_buf darwin_regexec_buf > + > +#endif This iteration looks much easier to grok, at least to me. Two things: * The name of the header, , sounds so nice and central, that those who care a lot more about macOS than I do may want to consolidate other support for the peculiarities macOS has also into it. I personally do not have a strong opinion. * We'd need a comment near the beginning of Makefile, like other symbolis like NO_FINK and NO_APPLE_COMMMON_CRYPTO do, to tell the users when to define this new symbol. The latter I would feel strong enough, so here is a sample update in a squashable form. If you have reasons to send a new iteration, you are free to include it. After waiting for comments from others for a few days, if you still don't have reasons to send an update, you can just tell me to squash the change on my end (if you agree with the change, that is). diff --git c/Makefile w/Makefile index 81075c38a2..ed2868ce10 100644 --- c/Makefile +++ w/Makefile @@ -110,6 +110,9 @@ include shared.mak # Define USE_HOMEBREW_LIBICONV to link against libiconv installed by # Homebrew, if present. # +# Define DARWIN_REGEXEC if regexec() in your platform regex library +# leaks when fed an invalid UTF-8 sequence. +# # Define NO_APPLE_COMMON_CRYPTO if you are building on Darwin/Mac OS X # and do not want to use Apple's CommonCrypto library. This allows you # to provide your own OpenSSL library, for example from MacPorts.