mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-03 20:22:38 +00:00
Fix s390x rax2 -I & memleak (#18151)
This commit is contained in:
parent
b69355bb84
commit
a637aa281d
@ -576,16 +576,14 @@ dotherax:
|
||||
return true;
|
||||
} else if (flags & (1 << 23)) { // -I
|
||||
if (strchr (str, '.')) {
|
||||
ut32 ip32 = 0;
|
||||
ut8 *ip = (ut8*)&ip32;
|
||||
sscanf (str, "%hhd.%hhd.%hhd.%hhd", &ip[0], &ip[1], &ip[2], &ip[3]);
|
||||
ut8 ip[4];
|
||||
sscanf (str, "%hhd.%hhd.%hhd.%hhd", ip, ip + 1, ip + 2, ip + 3);
|
||||
ut32 ip32 = ip[0] | (ip[1] << 8) | (ip[2] << 16) | (ip[3] << 24);
|
||||
printf ("0x%08x\n", ip32);
|
||||
} else {
|
||||
ut32 ip32 = (ut32)r_num_math (NULL, str);
|
||||
ut8 *ip = (ut8*)&ip32;
|
||||
char ipaddr[32];
|
||||
snprintf (ipaddr, sizeof (ipaddr), "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
printf ("%s\n", ipaddr);
|
||||
ut8 ip[4] = { ip32 & 0xff, (ip32 >> 8) & 0xff, (ip32 >> 16) & 0xff, ip32 >> 24 };
|
||||
printf ("%d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -643,6 +641,7 @@ R_API int r_main_rax2(int argc, const char **argv) {
|
||||
char *argv_i = strdup (argv[i]);
|
||||
r_str_unescape (argv_i);
|
||||
rax (num, argv_i, 0, i == argc - 1, &flags, &fm);
|
||||
free (argv_i);
|
||||
}
|
||||
}
|
||||
r_num_free (num);
|
||||
|
@ -758,6 +758,7 @@ R_API int r_sys_cmd_str_full(const char *cmd, const char *input, char **output,
|
||||
} else {
|
||||
free (outputptr);
|
||||
}
|
||||
free (mysterr);
|
||||
return ret;
|
||||
}
|
||||
return false;
|
||||
|
@ -6,6 +6,14 @@ EXPECT=<<EOF
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=rax2 -I 185.172.110.210
|
||||
FILE=-
|
||||
CMDS=!rax2 -I 185.172.110.210
|
||||
EXPECT=<<EOF
|
||||
0xd26eacb9
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=rax2 =10 0x46
|
||||
FILE=-
|
||||
CMDS=!rax2 =10 0x46
|
||||
|
Loading…
x
Reference in New Issue
Block a user