Skip to content
Myr

Fix undefined pointer arithmetic in UTF-8 helpers

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes GHSA-ggc9-rpv2-xgpm and GHSA-gvwx-xj9r-3frq.

authored by theyoucheng · committed by itchyny · parent a829f67 · Browse files · 1 file+3 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−2 removed

  • other:+3 added−2 removed

1 file+3 added−2 removed

modified:src/jv_unicode.c+3 added-2 removed
13 unmodified lines
14 return min;15 }16 int length = 0;17 int seen = 1;18 while (start >= min && (length = utf8_coding_length[(unsigned char)*start]) == UTF8_CONTINUATION_BYTE) {18 while ((length = utf8_coding_length[(unsigned char)*start]) == UTF8_CONTINUATION_BYTE) {19 if (start == min) break;20 start--;21 seen++;22 }23 if (length == 0 || length == UTF8_CONTINUATION_BYTE || length - seen < 0) {
17 unmodified lines
41 length = 1;42 } else if (length == 0 || length == UTF8_CONTINUATION_BYTE) {43 /* Bad single byte - either an invalid byte or an out-of-place continuation byte */44 length = 1;44 } else if (in + length > end) {45 } else if (length > end - in) {46 /* String ends before UTF8 sequence ends */47 length = end - in;48 } else {49 codepoint = ((unsigned)in[0]) & utf8_coding_bits[first];
90 unmodified lines