Fix undefined pointer arithmetic in UTF-8 helpers
Fixes GHSA-ggc9-rpv2-xgpm and GHSA-gvwx-xj9r-3frq.
This commit is contained in:
1 parent
a829f678f3
commit
df924eae91
1 file changed
+3
-2
+3
-2
@@ -15,7 +15,8 @@ const char* jvp_utf8_backtrack(const char* start, const char* min, int *missing_
|
|||||||
}
|
}
|
||||||
int length = 0;
|
int length = 0;
|
||||||
int seen = 1;
|
int seen = 1;
|
||||||
while (start >= min && (length = utf8_coding_length[(unsigned char)*start]) == UTF8_CONTINUATION_BYTE) {
|
while ((length = utf8_coding_length[(unsigned char)*start]) == UTF8_CONTINUATION_BYTE) {
|
||||||
|
if (start == min) break;
|
||||||
start--;
|
start--;
|
||||||
seen++;
|
seen++;
|
||||||
}
|
}
|
||||||
@@ -41,7 +42,7 @@ const char* jvp_utf8_next(const char* in, const char* end, int* codepoint_ret) {
|
|||||||
} else if (length == 0 || length == UTF8_CONTINUATION_BYTE) {
|
} else if (length == 0 || length == UTF8_CONTINUATION_BYTE) {
|
||||||
/* Bad single byte - either an invalid byte or an out-of-place continuation byte */
|
/* Bad single byte - either an invalid byte or an out-of-place continuation byte */
|
||||||
length = 1;
|
length = 1;
|
||||||
} else if (in + length > end) {
|
} else if (length > end - in) {
|
||||||
/* String ends before UTF8 sequence ends */
|
/* String ends before UTF8 sequence ends */
|
||||||
length = end - in;
|
length = end - in;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user