From 4eec87cdf6bea84584706efeac7a40ed7153e132 Mon Sep 17 00:00:00 2001 From: pancake Date: Sat, 14 Jul 2018 10:58:19 +0200 Subject: [PATCH] More warnings fixed --- libr/bin/format/pe/pe.c | 11 +++++++---- libr/core/cmd_help.c | 4 ++-- libr/core/cmd_print.c | 4 ++-- libr/debug/p/native/linux/linux_debug.c | 2 +- shlr/grub/fs/hfs.c | 2 +- shlr/grub/fs/hfsplus.c | 3 ++- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/libr/bin/format/pe/pe.c b/libr/bin/format/pe/pe.c index 2dfb48d0e7..53df3ceecd 100644 --- a/libr/bin/format/pe/pe.c +++ b/libr/bin/format/pe/pe.c @@ -2766,10 +2766,13 @@ static bool get_rsds(ut8* dbg_data, int dbg_data_len, SCV_RSDS_HEADER* res) { return true; } -static void get_nb10(ut8* dbg_data, SCV_NB10_HEADER* res) { +static void get_nb10(ut8* dbg_data, int dbg_data_len, SCV_NB10_HEADER* res) { const int nb10sz = 16; - // memcpy (res, dbg_data, nb10sz); - // res->file_name = (ut8*) strdup ((const char*) dbg_data + nb10sz); + if (dbg_data_len < nb10sz) { + return; + } + memcpy (res, dbg_data, nb10sz); + res->file_name = (ut8*) strdup ((const char*) dbg_data + nb10sz); } static int get_debug_info(struct PE_(r_bin_pe_obj_t)* bin, PE_(image_debug_directory_entry)* dbg_dir_entry, ut8* dbg_data, int dbg_data_len, SDebugInfo* res) { @@ -2814,7 +2817,7 @@ static int get_debug_info(struct PE_(r_bin_pe_obj_t)* bin, PE_(image_debug_direc } SCV_NB10_HEADER nb10_hdr = {{0}}; init_cv_nb10_header (&nb10_hdr); - get_nb10 (dbg_data, &nb10_hdr); + get_nb10 (dbg_data, dbg_data_len, &nb10_hdr); snprintf (res->guidstr, sizeof (res->guidstr), "%x%x", nb10_hdr.timestamp, nb10_hdr.age); res->file_name[0] = 0; diff --git a/libr/core/cmd_help.c b/libr/core/cmd_help.c index 4275466c3f..153fcaa010 100644 --- a/libr/core/cmd_help.c +++ b/libr/core/cmd_help.c @@ -497,8 +497,8 @@ static int cmd_help(void *data, const char *input) { /* binary and floating point */ r_str_bits64 (out, n); f = d = core->num->fvalue; - memcpy (&f, &n, sizeof(f)); - memcpy (&d, &n, sizeof(d)); + memcpy (&f, &n, sizeof (f)); + memcpy (&d, &n, sizeof (d)); /* adjust sign for nan floats, different libcs are confused */ if (isnan (f) && signbit (f)) { f = -f; diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index 267b536070..1cac5ce8d3 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -3674,13 +3674,13 @@ R_API void r_print_code(RPrint *p, ut64 addr, ut8 *buf, int len, char lang) { static int cmd_print(void *data, const char *input) { RCore *core = (RCore *) data; - int w, p, i, l, len, ret; + int i, l, len, ret; ut8* block; ut32 tbs = core->blocksize; ut64 n, off, from, to, at, ate, piece; ut64 tmpseek = UT64_MAX; const int addrbytes = core->io->addrbytes; - w = p = i = l = len = ret = 0; + i = l = len = ret = 0; n = off = from = to = at = ate = piece = 0; r_print_init_rowoffsets (core->print); diff --git a/libr/debug/p/native/linux/linux_debug.c b/libr/debug/p/native/linux/linux_debug.c index dd97eedddf..8954381c90 100644 --- a/libr/debug/p/native/linux/linux_debug.c +++ b/libr/debug/p/native/linux/linux_debug.c @@ -125,7 +125,7 @@ int linux_handle_signals (RDebug *dbg) { eprintf ("[+] SIGNAL %d errno=%d addr=0x%08"PFMT64x " code=%d ret=%d\n", siginfo.si_signo, siginfo.si_errno, - (ut64)siginfo.si_addr, siginfo.si_code, ret); + (ut64)(size_t)siginfo.si_addr, siginfo.si_code, ret); } return true; } diff --git a/shlr/grub/fs/hfs.c b/shlr/grub/fs/hfs.c index aa8db6d628..dbd25437ca 100644 --- a/shlr/grub/fs/hfs.c +++ b/shlr/grub/fs/hfs.c @@ -1175,7 +1175,7 @@ grub_hfs_uuid (grub_device_t device, char **uuid) data = grub_hfs_mount (device->disk); if (data && data->sblock.num_serial != 0) { - *uuid = grub_xasprintf ("%016llx", + *uuid = grub_xasprintf ("%016"PFMT64x, (unsigned long long) grub_be_to_cpu64 (data->sblock.num_serial)); } diff --git a/shlr/grub/fs/hfsplus.c b/shlr/grub/fs/hfsplus.c index 38bc03826a..d529f395e8 100644 --- a/shlr/grub/fs/hfsplus.c +++ b/shlr/grub/fs/hfsplus.c @@ -29,6 +29,7 @@ #include #include #include +#include #define GRUB_HFSPLUS_MAGIC 0x482B #define GRUB_HFSPLUSX_MAGIC 0x4858 @@ -1039,7 +1040,7 @@ grub_hfsplus_uuid (grub_device_t device, char **uuid) data = grub_hfsplus_mount (disk); if (data) { - *uuid = grub_xasprintf ("%016llx", + *uuid = grub_xasprintf ("%016"PFMT64x, (unsigned long long) grub_be_to_cpu64 (data->volheader.num_serial)); }