Skip to content

Commit c8e4f31

Browse files
committedJul 18, 2022
Fix legacy conversion filter for ISO-2022-KR
When I was working on this code before, it really, really looked like the index into `uhc3_ucs_table` could never overrun the size of the table. Why did I get this wrong? Don't know. Anyways, libfuzzer tore away my illusions and unequivocally demonstrated that the index CAN be larger than the size of the table.
1 parent cebb800 commit c8e4f31

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎ext/mbstring/libmbfl/filters/mbfilter_iso2022_kr.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@ int mbfl_filt_conv_2022kr_wchar(int c, mbfl_convert_filter *filter)
125125
}
126126
} else {
127127
w = (c1 - 0x47)*94 + c - 0x21;
128-
ZEND_ASSERT(w < uhc3_ucs_table_size);
129-
w = uhc3_ucs_table[w];
128+
if (w < uhc3_ucs_table_size) {
129+
w = uhc3_ucs_table[w];
130+
} else {
131+
w = MBFL_BAD_INPUT;
132+
}
130133
}
131134

132135
if (w <= 0) {

0 commit comments

Comments
 (0)