Fix bigendian pointer dereference

This commit is contained in:
trndr 2014-11-13 17:25:31 +00:00 committed by pancake
parent 188bc3ec39
commit 2ab0dce285
2 changed files with 10 additions and 18 deletions

View File

@ -103,28 +103,19 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
}
// pop state
if (ok) *ok = 1;
ut64 num = 0;
switch (refsz) {
case 8: {
ut64 num = 0;
(void)r_io_read_at (core->io, n, (ut8*)&num, sizeof (num));
return num; }
case 4: {
ut32 num = 0;
(void)r_io_read_at (core->io, n, (ut8*)&num, sizeof (num));
return num; }
case 2: {
ut16 num = 0;
(void)r_io_read_at (core->io, n, (ut8*)&num, sizeof (num));
return num; }
case 1: {
ut8 num = 0;
(void)r_io_read_at (core->io, n, (ut8*)&num, sizeof (num));
return num; }
case 8:
case 4:
case 2:
case 1:
(void)r_io_read_at (core->io, n, (ut8*)&num, refsz);
r_mem_copyendian ((ut8*)&num, (ut8*)&num, refsz, !core->assembler->big_endian);
return num;
default:
eprintf ("Invalid reference size: %d (%s)\n", refsz, str);
break;
return 0LL;
}
return 0LL;
} else
if (str[0]=='$') {
if (ok) *ok = 1;

View File

@ -1552,6 +1552,7 @@ static void handle_print_ptr (RCore *core, RDisasmState *ds, int len, int idx) {
case 4: n &= UT32_MAX; break;
case 8: n &= UT64_MAX; break;
}
r_mem_copyendian ((ut8*)&n, (ut8*)&n, ds->analop.refptr, !core->assembler->big_endian);
n32 = n;
handle_comment_align (core, ds);