on master help sign in
vty_set_custom_table_range: avoid overflow in test
commitb988b6894e81881b75febbf00a7671d7ae6c8f15 authorJonathan Daugherty <cygnus@foobox.com> dateThu 5 Mar 2020, 14:19 (7 years ago) parent24b9c8c
1 file changed+4−2
cbits/mk_wcwidth.c+4−2
cbits/mk_wcwidth.c+4−2
@@ -286,11 +286,13 @@ int vty_init_custom_table(int size)
286286int vty_set_custom_table_range(uint32_t start, uint32_t size, uint8_t width)
287287{
288288 if ((custom_table == NULL) ||
289− ((start + size - 1) >= custom_table_size) ||
289+ (size >= custom_table_size) ||
290+ (start >= custom_table_size) ||
291+ ((start + 1) >= (custom_table_size - size)) ||
290292 custom_table_ready) {
291293 return 1;
292294 } else {
293− memset(custom_table + start, (uint8_t) width, size);
295+ memset(custom_table + start, width, size);
294296 return 0;
295297 }
296298}