Fix null deref assert in pdj ##crash

This commit is contained in:
pancake 2023-09-20 15:39:45 +02:00
parent ac752dd4f0
commit 969fa6e3f6
3 changed files with 11 additions and 9 deletions

View File

@ -20,9 +20,9 @@ R_LIB_VERSION (r_bin);
#define R_BIN_LDR_STATIC_PLUGINS 0
#endif
static const RBinPlugin *bin_static_plugins[] = { R_BIN_STATIC_PLUGINS, NULL };
static const RBinXtrPlugin *bin_xtr_static_plugins[] = { R_BIN_XTR_STATIC_PLUGINS, NULL };
static const RBinLdrPlugin *bin_ldr_static_plugins[] = { R_BIN_LDR_STATIC_PLUGINS, NULL };
static RBinPlugin *bin_static_plugins[] = { R_BIN_STATIC_PLUGINS, NULL };
static RBinXtrPlugin *bin_xtr_static_plugins[] = { R_BIN_XTR_STATIC_PLUGINS, NULL };
static RBinLdrPlugin *bin_ldr_static_plugins[] = { R_BIN_LDR_STATIC_PLUGINS, NULL };
static int __getoffset(RBin *bin, int type, int idx) {
RBinFile *a = r_bin_cur (bin);

View File

@ -6841,18 +6841,20 @@ R_API int r_core_print_disasm_json(RCore *core, ut64 addr, ut8 *buf, int nb_byte
}
ret = r_asm_disassemble (core->rasm, &asmop, buf + i, nb_bytes - i);
if (ret < 1) {
char *hex = r_asm_op_get_hex (&asmop);
pj_o (pj);
pj_kn (pj, "offset", at);
pj_ki (pj, "size", 1);
pj_ks (pj, "bytes", hex);
if (asmop.bytes) {
char *hex = r_asm_op_get_hex (&asmop);
pj_ks (pj, "bytes", hex);
free (hex);
}
pj_ks (pj, "type", "invalid");
pj_end (pj);
i++;
k++;
j++;
result = true;
free (hex);
continue;
}

View File

@ -364,11 +364,11 @@ R_API int r_hex_pair2bin(const char *arg) {
}
R_API int r_hex_bin2str(const ut8 *in, int len, char *out) {
int i, idx;
char tmp[8];
if (len < 0) {
if (!in || len < 0) {
return 0;
}
int i, idx;
char tmp[8];
for (idx = i = 0; i < len; i++, idx += 2) {
r_hex_from_byte (tmp, in[i]);
memcpy (out + idx, tmp, 2);