pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Add a slightly ugly but minimal fix for 32-bit OSes, where pointers cast to int types might be negative.



Module Name:	pkgsrc-wip
Committed By:	Havard Eidnes <he%NetBSD.org@localhost>
Pushed By:	he
Date:		Sun Jul 14 00:48:14 2019 +0200
Changeset:	a08a5b97b2d91e3f0ecaddf399dcf7d0344d1bae

Modified Files:
	quickjs/distinfo
Added Files:
	quickjs/patches/patch-libregexp.c

Log Message:
Add a slightly ugly but minimal fix for 32-bit OSes,
where pointers cast to int types might be negative.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=a08a5b97b2d91e3f0ecaddf399dcf7d0344d1bae

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 quickjs/distinfo                  |  1 +
 quickjs/patches/patch-libregexp.c | 66 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+)

diffs:
diff --git a/quickjs/distinfo b/quickjs/distinfo
index 9b3064d432..ce26d13320 100644
--- a/quickjs/distinfo
+++ b/quickjs/distinfo
@@ -6,6 +6,7 @@ SHA512 (quickjs-2019-07-09.tar.xz) = db2498659ae1c22e5c0a24e0f2d582db6003e18a182
 Size (quickjs-2019-07-09.tar.xz) = 737248 bytes
 SHA1 (patch-Makefile) = d96c2a797bb9bc7becc7f1217fc3d3457527d55f
 SHA1 (patch-cutils.h) = 9719a77add566ce6443af1ac2ba1d1ea61e5c248
+SHA1 (patch-libregexp.c) = 3ef3f22022d8d791b88d376ff426c4d41fc2eeb3
 SHA1 (patch-qjs.c) = d26b8ac0f7bf84bdb17fb4784f637dcb012cbd93
 SHA1 (patch-qjsc.c) = 58733721d4e4647737d111e8835b4c1016ea2889
 SHA1 (patch-quickjs-libc.c) = 2257ad069d9a9232d6a3e1c5ae0530d08a1b1010
diff --git a/quickjs/patches/patch-libregexp.c b/quickjs/patches/patch-libregexp.c
new file mode 100644
index 0000000000..951b92f067
--- /dev/null
+++ b/quickjs/patches/patch-libregexp.c
@@ -0,0 +1,66 @@
+$NetBSD$
+
+Fix issue found on 32-bit ports, where pointers could end up
+as negative values when cast to intptr_t.
+
+--- libregexp.c.orig	2019-07-09 17:49:47.000000000 +0000
++++ libregexp.c
+@@ -2027,8 +2027,9 @@ static int push_state(REExecContext *s,
+     return 0;
+ }
+ 
++/* Comment is misleading: can also return int'ed pointer */
+ /* return 1 if match, 0 if not match or -1 if error. */
+-static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
++static uintptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
+                                    StackInt *stack, int stack_len,
+                                    const uint8_t *pc, const uint8_t *cptr,
+                                    BOOL no_recurse)
+@@ -2049,7 +2050,7 @@ static intptr_t lre_exec_backtrack(REExe
+             {
+                 REExecState *rs;
+                 if (no_recurse)
+-                    return (intptr_t)cptr;
++                    return (uintptr_t)cptr;
+                 ret = 1;
+                 goto recurse;
+             no_match:
+@@ -2393,7 +2394,7 @@ static intptr_t lre_exec_backtrack(REExe
+             {
+                 uint32_t next_pos, quant_min, quant_max;
+                 size_t q;
+-                intptr_t res;
++                uintptr_t res;
+                 const uint8_t *pc1;
+                 
+                 next_pos = get_u32(pc);
+@@ -2407,7 +2408,7 @@ static intptr_t lre_exec_backtrack(REExe
+                 for(;;) {
+                     res = lre_exec_backtrack(s, capture, stack, stack_len,
+                                              pc1, cptr, TRUE);
+-                    if (res < 0)
++                    if (res == (uintptr_t)-1)
+                         return res;
+                     if (!res)
+                         break;
+@@ -2443,7 +2444,8 @@ int lre_exec(uint8_t **capture,
+              int cbuf_type, void *opaque)
+ {
+     REExecContext s_s, *s = &s_s;
+-    int re_flags, i, alloca_size, ret;
++    int re_flags, i, alloca_size;
++    uintptr_t ret;
+     StackInt *stack_buf;
+     
+     re_flags = bc_buf[RE_HEADER_FLAGS];
+@@ -2473,7 +2475,9 @@ int lre_exec(uint8_t **capture,
+     ret = lre_exec_backtrack(s, capture, stack_buf, 0, bc_buf + RE_HEADER_LEN,
+                              cbuf + (cindex << cbuf_type), FALSE);
+     lre_realloc(s->opaque, s->state_stack, 0);
+-    return ret;
++    if (ret == (uintptr_t)-1)
++	return -1;
++    return (int)ret;
+ }
+ 
+ int lre_get_capture_count(const uint8_t *bc_buf)


Home | Main Index | Thread Index | Old Index