git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] t4062: stop using repetition in regex

From
René Scharfe <l.s.r@web.de>
Date
Aug 8, 2017, 15:18 UTC
Message-ID
<1e7ed028-77fe-195a-4acf-6c80d1704463@web.de>
In-Reply-To
<alpine.DEB.2.21.1.1708081648130.11175@virtualbox>
Am 08.08.2017 um 16:49 schrieb Johannes Schindelin:
Show 15 quoted lines
> Hi René,
> 
> On Tue, 8 Aug 2017, René Scharfe wrote:
> 
>> OpenBSD's regex library has a repetition limit (RE_DUP_MAX) of 255.
>> That's the minimum acceptable value according to POSIX.  In t4062 we use
>> 4096 repetitions in the test "-G matches", though, causing it to fail.
>>
>> Do the same as the test "-S --pickaxe-regex" in the same file and search
>> for a single zero instead.  That still suffices to trigger the buffer
>> overrun in older versions (checked with b7d36ffca02^ and --valgrind on
>> Linux), simplifies the test a bit, and avoids exceeding OpenBSD's limit.
> 
> I am afraid not. The 4096 is precisely the page size required to trigger
> the bug on Windows against which this regression test tries to safeguard.

Checked with b7d36ffca02^ on MinGW now as well and found that it segfaults with the proposed change ten out of ten times.

You get different results? How is that possible? The search string is NUL-terminated in each case, while the point of the test is that the file contents isn't, right?

> Maybe simply disable the test on OpenBSD instead? Or guard the {4096}
> behind the MINGW prereq.

It's easy to build a long search string with two repetitions or by using a longer string as the base, if necessary. But first we need to find out why regexec() doesn't overflow in your case. My build uses the version from compat/. Why would it stop before reaching a NUL? That sounds like a different and serious bug.

Thanks, René

Previous: Johannes SchindelinNext: Junio C Hamano
Message 3 of 17 in “t4062: stop using repetition in regex”
  1. t4062: stop using repetition in regexRené Scharfe, Aug 8, 2017
  2. Johannes SchindelinAug 8, 2017
  3. René ScharfeAug 8, 2017
  4. Junio C HamanoAug 8, 2017
  5. Junio C HamanoAug 8, 2017
  6. René ScharfeAug 8, 2017
  7. Junio C HamanoAug 9, 2017
  8. René ScharfeAug 9, 2017
  9. René ScharfeAug 9, 2017
  10. David CoppaAug 9, 2017
  11. Johannes SchindelinAug 9, 2017
  12. Junio C HamanoAug 9, 2017
  13. René ScharfeAug 9, 2017
  14. Junio C HamanoAug 9, 2017
  15. René ScharfeAug 10, 2017
  16. Junio C HamanoAug 11, 2017
  17. René ScharfeAug 8, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.