From 5f941cddb125c540bfbdc3ebf8a582cd480a4a8a Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 9 Feb 2023 17:30:31 +0100 Subject: [PATCH] Apply some more minor fixes written offline --- libr/arch/p/6502/plugin.c | 1 - libr/arch/p/null/plugin.c | 2 +- libr/bin/p/bin_bf.c | 3 ++- libr/bin/p/bin_bios.c | 4 ++-- libr/bin/p/bin_bootimg.c | 2 +- libr/bin/p/bin_coff.c | 11 ----------- libr/bin/p/bin_dbginfo_elf.c | 2 +- libr/bin/p/bin_dbginfo_p9.c | 2 +- libr/bin/p/bin_java.c | 5 ----- libr/bin/p/bin_ldr_linux.c | 2 +- libr/util/sstext.c | 4 ++++ 11 files changed, 13 insertions(+), 25 deletions(-) diff --git a/libr/arch/p/6502/plugin.c b/libr/arch/p/6502/plugin.c index f187a9d2a2..295e47fdf9 100644 --- a/libr/arch/p/6502/plugin.c +++ b/libr/arch/p/6502/plugin.c @@ -301,7 +301,6 @@ static void _6502_anal_esil_flags(RAnalOp *op, ut8 data0) { enabled = 0; flag = 'V'; break; - break; } r_strbuf_setf (&op->esil, "%d,%c,=", enabled, flag); } diff --git a/libr/arch/p/null/plugin.c b/libr/arch/p/null/plugin.c index 790323964a..a17fb0c3d4 100644 --- a/libr/arch/p/null/plugin.c +++ b/libr/arch/p/null/plugin.c @@ -5,7 +5,7 @@ RArchPlugin r_arch_plugin_null = { .name = "null", - .desc = "Fallback/Null archysis plugin", + .desc = "Fallback/Null arch plugin", .arch = "none", .license = "LGPL3", .bits = R_SYS_BITS_PACK4 (8, 16, 32, 64) diff --git a/libr/bin/p/bin_bf.c b/libr/bin/p/bin_bf.c index 923d17077b..f06cec5be6 100644 --- a/libr/bin/p/bin_bf.c +++ b/libr/bin/p/bin_bf.c @@ -7,7 +7,8 @@ static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *buf, ut64 loadadd } static void destroy(RBinFile *bf) { - r_buf_free (bf->o->bin_obj); + RBuffer *buf = R_UNWRAP3 (bf, o, bin_obj); + r_buf_free (buf); } static RList *strings(RBinFile *bf) { diff --git a/libr/bin/p/bin_bios.c b/libr/bin/p/bin_bios.c index edcd057e04..55acd21c80 100644 --- a/libr/bin/p/bin_bios.c +++ b/libr/bin/p/bin_bios.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2013-2019 - pancake */ +/* radare - LGPL - Copyright 2013-2023 - pancake */ #include #include "../i/private.h" @@ -19,7 +19,7 @@ static bool check_buffer(RBinFile *bf, RBuffer *buf) { const ut32 ep = sz - 0x10000 + 0xfff0; /* F000:FFF0 address */ /* hacky check to avoid detecting multidex or MZ bins as bios */ /* need better fix for this */ - ut8 tmp[3]; + ut8 tmp[3] = {0}; int r = r_buf_read_at (buf, 0, tmp, sizeof (tmp)); if (r <= 0 || !memcmp (tmp, "dex", 3) || !memcmp (tmp, "MZ", 2)) { return false; diff --git a/libr/bin/p/bin_bootimg.c b/libr/bin/p/bin_bootimg.c index 09a927e385..71044f3c2f 100644 --- a/libr/bin/p/bin_bootimg.c +++ b/libr/bin/p/bin_bootimg.c @@ -140,7 +140,7 @@ static bool check_buffer(RBinFile *bf, RBuffer *buf) { } static RList *entries(RBinFile *bf) { - BootImageObj *bio = bf->o->bin_obj; + BootImageObj *bio = R_UNWRAP3 (bf, o, bin_obj); RBinAddr *ptr = NULL; if (!bio) { return NULL; diff --git a/libr/bin/p/bin_coff.c b/libr/bin/p/bin_coff.c index 73508157e1..caecf55a53 100644 --- a/libr/bin/p/bin_coff.c +++ b/libr/bin/p/bin_coff.c @@ -662,15 +662,6 @@ static RBinInfo *info(RBinFile *bf) { return ret; } -static RList *fields(RBinFile *bf) { - return NULL; -} - - -static ut64 size(RBinFile *bf) { - return 0; -} - static bool check_buffer(RBinFile *bf, RBuffer *buf) { #if 0 TODO: do more checks here to avoid false positives @@ -703,8 +694,6 @@ RBinPlugin r_bin_plugin_coff = { .symbols = &symbols, .imports = &imports, .info = &info, - .fields = &fields, - .size = &size, .libs = &libs, .relocs = &relocs, .patch_relocs = &patch_relocs diff --git a/libr/bin/p/bin_dbginfo_elf.c b/libr/bin/p/bin_dbginfo_elf.c index 4a10f3493f..dcafe5aff5 100644 --- a/libr/bin/p/bin_dbginfo_elf.c +++ b/libr/bin/p/bin_dbginfo_elf.c @@ -12,7 +12,7 @@ static bool get_line(RBinFile *bf, ut64 addr, char *file, int len, int *line) { char *p = strchr (ret, '|'); if (p) { *p = '\0'; - strncpy (file, ret, len); + r_str_ncpy (file, ret, len); *line = atoi (p + 1); return true; } diff --git a/libr/bin/p/bin_dbginfo_p9.c b/libr/bin/p/bin_dbginfo_p9.c index 396e0a925f..dd9670784e 100644 --- a/libr/bin/p/bin_dbginfo_p9.c +++ b/libr/bin/p/bin_dbginfo_p9.c @@ -11,7 +11,7 @@ static bool get_line(RBinFile *bf, ut64 addr, char *file, int len, int *line) { char *p = strchr (ret, '|'); if (p) { *p = '\0'; - strncpy (file, ret, len); + r_str_ncpy (file, ret, len); *line = atoi (p + 1); return true; } diff --git a/libr/bin/p/bin_java.c b/libr/bin/p/bin_java.c index c0ad4171b6..72fa2dc562 100644 --- a/libr/bin/p/bin_java.c +++ b/libr/bin/p/bin_java.c @@ -186,10 +186,6 @@ static RList *imports(RBinFile *bf) { return r_bin_java_get_imports (bf->o->bin_obj); } -static RList *fields(RBinFile *bf) { - return NULL;// r_bin_java_get_fields (bf->o->bin_obj); -} - static RList *libs(RBinFile *bf) { return r_bin_java_get_lib_names (bf->o->bin_obj); } @@ -211,7 +207,6 @@ RBinPlugin r_bin_plugin_java = { .imports = &imports, .strings = &strings, .info = &info, - .fields = fields, .libs = libs, .lines = &lines, .classes = classes, diff --git a/libr/bin/p/bin_ldr_linux.c b/libr/bin/p/bin_ldr_linux.c index 7a8db37f36..78481c71a7 100644 --- a/libr/bin/p/bin_ldr_linux.c +++ b/libr/bin/p/bin_ldr_linux.c @@ -9,7 +9,7 @@ static bool load(RBin *bin) { if (!bin->file) { bin->file = bin->cur->file; } - return bin->cur->xtr_obj? true : false; + return bin->cur->xtr_obj != NULL; } diff --git a/libr/util/sstext.c b/libr/util/sstext.c index 1f52fa498e..879930af7b 100644 --- a/libr/util/sstext.c +++ b/libr/util/sstext.c @@ -449,6 +449,10 @@ static const SevenSegments ss[] = { " ", " & " } }, + { '@', { " ", + " ", + " @ " } + }, { '\0', {0}} };