~sircmpwn/hare-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH hare] regex: require quantifier minimum in range

Details
Message ID
<20220426063949.29971-1-mail@nprescott.com>
DKIM signature
pass
Download raw message
Patch: +11 -3
Intended to address https://todo.sr.ht/~sircmpwn/hare/633 where
valgrind flags a conditional jump on uninitialized value(s) stemming
from regex.parse_repetition. The source of the uninitialized value
isn't called out in the ticket but is visible with:

  valgrind --track-origins=yes .bin/hare-tests regex::find

The POSIX ERE grammar[0] does not specify a quantifier syntax with
undefined minimums (e.g. `{,2}`), this patch will error in such a case
rather than use the void value with `rep_parts.0`

0: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_05_03
Signed-off-by: Nolan Prescott <mail@nprescott.com>
---
 regex/+test.ha | 10 +++++++---
 regex/regex.ha |  4 ++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/regex/+test.ha b/regex/+test.ha
index 5f59d04f..d28b41cc 100644
--- a/regex/+test.ha
+++ b/regex/+test.ha
@@ -304,13 +304,17 @@ fn run_findall_case(
		(`^a\|b$`, "a|b", matchres::MATCH, 0, -1),
		(`^a\.b$`, "a.b", matchres::MATCH, 0, -1),
		(`^a\\b$`, "a\\b", matchres::MATCH, 0, -1),
		(`^x(abc)\{,2\}$`, "xabc{,2}", matchres::MATCH, 0, -1),
		(`^x(abc)\{,2\}$`, "xabcabc{,2}", matchres::NOMATCH, 0, -1),
		// {m,n}
		(`^x(abc){2}$`, "xabcabc", matchres::MATCH, 0, -1),
		(`^x(abc){3}$`, "xabcabc", matchres::NOMATCH, 0, -1),
		(`^x(abc){1,2}$`, "xabc", matchres::MATCH, 0, -1),
		(`^x(abc){1,2}$`, "xabcabc", matchres::MATCH, 0, -1),
		(`^x(abc){1,2}$`, "xabcabcabc", matchres::NOMATCH, 0, -1),
		(`^x(abc){,2}$`, "xabc", matchres::MATCH, 0, -1),
		(`^x(abc){,2}$`, "xabcabc", matchres::MATCH, 0, -1),
		(`^x(abc){,2}$`, "xabcabcabc", matchres::NOMATCH, 0, -1),
		(`^x(abc){,2}$`, "xabc", matchres::ERROR, 0, -1),
		(`^x(abc){,2}$`, "xabcabc", matchres::ERROR, 0, -1),
		(`^x(abc){,2}$`, "xabcabcabc", matchres::ERROR, 0, -1),
		(`^x(abc){1,}$`, "xabc", matchres::MATCH, 0, -1),
		(`^x(abc){1,}$`, "xabcabc", matchres::MATCH, 0, -1),
		(`^x(abc){3,}$`, "xabcabc", matchres::NOMATCH, 0, -1),
diff --git a/regex/regex.ha b/regex/regex.ha
index c49be630..6de4f374 100644
--- a/regex/regex.ha
+++ b/regex/regex.ha
@@ -454,6 +454,10 @@ fn parse_repetition(
		};
	};

	if (len(min_str) == 0 && len(max_str) > 0) {
		return "Invalid repetition minimum value": error;
	};

	const rep_len = if (is_single_arg) {
		yield len(min_str);
	} else {
-- 
2.32.0

[hare/patches] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CJJYV2DT34TP.2RXMWTFJN8NOZ@cirno2>
In-Reply-To
<20220426063949.29971-1-mail@nprescott.com> (view parent)
DKIM signature
missing
Download raw message
hare/patches: SUCCESS in 1m31s

[regex: require quantifier minimum in range][0] from [Nolan Prescott][1]

[0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/31598
[1]: mail@nprescott.com

✓ #744615 SUCCESS hare/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/744615
✓ #744616 SUCCESS hare/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/744616
Details
Message ID
<CJJZYTO48BLR.328P23LCSTC62@taiga>
In-Reply-To
<20220426063949.29971-1-mail@nprescott.com> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
Thanks!

To git@git.sr.ht:~sircmpwn/hare
   85f25df5..1a118d90  master -> master
Reply to thread Export thread (mbox)