Skip to content

Commit b3424fc

Browse files
brianmarioreinerh
authored andcommitted
Don't advance our end pointer until we've checked we have enough buffer left and have peeked ahead to see that a unicode escape is approaching.
Thanks @kivikakk for helping me track down the actual bug here! Fixes: CVE-2017-16516 Origin: brianmario/yajl-ruby@a8ca8f4 Bug: lloyd/yajl#248 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040036
1 parent c71ba65 commit b3424fc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cdogs/yajl/yajl_encode.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ void yajl_string_decode(yajl_buf buf, const unsigned char * str,
139139
end+=3;
140140
/* check if this is a surrogate */
141141
if ((codepoint & 0xFC00) == 0xD800) {
142-
end++;
143-
if (str[end] == '\\' && str[end + 1] == 'u') {
142+
if (end + 2 < len && str[end + 1] == '\\' && str[end + 2] == 'u') {
143+
end++;
144144
unsigned int surrogate = 0;
145145
hexToDigit(&surrogate, str + end + 2);
146146
codepoint =

0 commit comments

Comments
 (0)