rax2 fix overflow (#8928)

* fix overflow

* pass NULL to r_print_hex_from_bin in rax2
This commit is contained in:
kriw 2017-12-02 16:15:23 +01:00 committed by radare
parent 96756b37c9
commit 551d7bebb6
2 changed files with 7 additions and 4 deletions

View File

@ -11,7 +11,6 @@
}
static RNum *num;
static RPrint *rp;
static int help();
static ut64 flags = 0;
static int use_stdin();
@ -432,7 +431,7 @@ dotherax:
return true;
} else if (flags & (1 << 19)) { // -L
r_print_hex_from_bin (rp, str);
r_print_hex_from_bin (NULL, str);
return true;
}
@ -520,7 +519,6 @@ static int use_stdin() {
int main(int argc, char **argv) {
int i;
num = r_num_new (NULL, NULL, NULL);
rp = r_print_new ();
if (argc == 1) {
use_stdin ();
} else {

View File

@ -1871,11 +1871,16 @@ R_API int r_print_jsondump(RPrint *p, const ut8 *buf, int len, int wordsize) {
R_API void r_print_hex_from_bin (RPrint *p, char *bin_str) {
int i, j, index;
const int len = strlen (bin_str);
ut64 n, *buf = malloc (len / 8);
ut64 n, *buf = malloc (sizeof (ut64) * ((len + 63) / 64));
if (buf == NULL) {
eprintf ("allocation failed\n");
return;
}
if (!p) {
p = &(RPrint){
.cb_printf = libc_printf,
};
}
for (i = len - 1, index = 0; i >= 0; i -= 64, index++) {
n = 0;
for (j = 0; j < 64 && i - j >= 0; j++) {