Fix heap buffer overflow found by ASAN

This commit is contained in:
Mohamed Lemine Ould El-Hadj 2023-01-28 18:28:41 -05:00 committed by pancake
parent 2e24d9e55f
commit 67fbe02de9

View File

@ -1881,7 +1881,7 @@ static const ut8 *parse_attr_value(const ut8 *obuf, int obuf_len, RBinDwarfAttrD
ut8 *section = NULL;
section = get_section_bytes (bin, section_name, &section_len);
if (section && value->string.offset < section_len) {
char *ds = r_str_ndup ((const char *)(section + value->string.offset), section_len);
char *ds = r_str_ndup ((const char *)(section + value->string.offset), section_len - 1);
if (ds) {
r_str_ansi_strip (ds);
r_str_replace_ch (ds, '\n', 0, true);