Skip to content

Commit

Permalink
fix #2969 - oob write (1 byte) in dex.c
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio authored and XVilka committed Aug 24, 2022
1 parent 95deff5 commit b8b2e66
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion librz/bin/format/dex/dex.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ static DexString *dex_string_new(RzBuffer *buf, ut64 offset, st64 *pread) {
DexString *string = NULL;

read = rz_buf_uleb128(buf, &size);
if (UT64_ADD_OVFCHK(size, 1)) {
return NULL;
}

data = malloc(size + 1);
if (!data || rz_buf_read(buf, (ut8 *)data, size) != size) {
free(data);
Expand Down Expand Up @@ -905,7 +909,9 @@ static char *dex_resolve_library(const char *library) {
}
char *demangled = strdup(library + 1);
rz_str_replace_ch(demangled, '/', '.', 1);
demangled[strlen(demangled) - 1] = 0;
if (RZ_STR_ISNOTEMPTY(demangled)) {
demangled[strlen(demangled) - 1] = 0;
}
return demangled;
}

Expand Down

0 comments on commit b8b2e66

Please sign in to comment.