Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Chungmin Lee <chungmin@chungminlee.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2] regexec: work around macOS TRE leak on invalid UTF-8
Date: Tue, 28 Jul 2026 17:41:34 -0700	[thread overview]
Message-ID: <xmqqse52bpa9.fsf@gitster.g> (raw)
In-Reply-To: <20260728052538.12429-1-chungmin@chungminlee.com> (Chungmin Lee's message of "Mon, 27 Jul 2026 22:25:38 -0700")

Chungmin Lee <chungmin@chungminlee.com> 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, <compat/darwin.h>, 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.



      reply	other threads:[~2026-07-29  0:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22  5:31 [PATCH] regexec: work around macOS TRE memory leak on invalid UTF-8 Chungmin Lee
2026-07-24  4:19 ` Junio C Hamano
2026-07-28  5:25 ` [PATCH v2] regexec: work around macOS TRE " Chungmin Lee
2026-07-29  0:41   ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqse52bpa9.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=chungmin@chungminlee.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox