From d64063466691f592b020f40ac37693f3514ffb99 Mon Sep 17 00:00:00 2001 From: pancake Date: Sat, 13 Feb 2021 02:59:34 +0100 Subject: [PATCH] Fix oobread in charset.c --- libr/util/charset.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libr/util/charset.c b/libr/util/charset.c index 5ac06f3ab3..7eb74ed8f8 100644 --- a/libr/util/charset.c +++ b/libr/util/charset.c @@ -122,11 +122,13 @@ R_API size_t r_charset_decode_str(RCharset *rc, ut8 *out, size_t out_len, const //zero terminate the string snprintf (k, sizeof (k), "%c", ch_in);//snprintf (k, sizeof (k), "0x%02x", ch_in); char *v = sdb_get (rc->db_char_to_hex, k, 0); - memmove(v, v+2, strlen (v)); + if (strlen (v) < 2) { + continue; + } //convert to ascii char str_hx[32]; - snprintf (str_hx, sizeof (str_hx), "%c", (char) strtol( v, 0, 16)); + snprintf (str_hx, sizeof (str_hx), "%c", (char) strtol( v+2, 0, 16)); const char *ret = r_str_get_fail (str_hx, "?"); strcpy (o, ret);