From 11ad0a732d083eb217398f5944978de3e2c0e67d Mon Sep 17 00:00:00 2001 From: radare Date: Thu, 14 Feb 2019 00:17:01 +0100 Subject: [PATCH] Fix #12725 - pf* exposes flag sizes via fl and Cd ##types (#13080) --- libr/bin/bfile.c | 9 ++++++--- libr/util/format.c | 10 +++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libr/bin/bfile.c b/libr/bin/bfile.c index ddf70cecd3..e67f61756d 100644 --- a/libr/bin/bfile.c +++ b/libr/bin/bfile.c @@ -853,7 +853,6 @@ R_API bool r_bin_file_hash(RBin *bin, ut64 limit, const char *file) { char hash[128], *p; RHash *ctx; ut64 buf_len = 0, r = 0; - int i; RBinFile *bf = bin->cur; if (!bf) { return false; @@ -895,8 +894,12 @@ R_API bool r_bin_file_hash(RBin *bin, ut64 limit, const char *file) { r_io_desc_seek (iod, r, R_IO_SEEK_SET); const size_t rem_len = buf_len-r; int b = r_io_desc_read (iod, buf, rem_len); - (void)r_hash_do_md5 (ctx, buf, rem_len); - (void)r_hash_do_sha1 (ctx, buf, rem_len); + if (b < 1) { + eprintf ("r_io_desc_read: error\n"); + } else { + (void)r_hash_do_md5 (ctx, buf, b); + (void)r_hash_do_sha1 (ctx, buf, b); + } } r_hash_do_end (ctx, R_HASH_MD5); p = hash; diff --git a/libr/util/format.c b/libr/util/format.c index c26e1dc8b2..d530cd3ef3 100644 --- a/libr/util/format.c +++ b/libr/util/format.c @@ -1500,7 +1500,7 @@ int r_print_format_struct_size(const char *f, RPrint *p, int mode, int n) { } i = 0; - if (IS_DIGIT(fmt[i])) { + if (IS_DIGIT (fmt[i])) { while (IS_DIGIT(fmt[i])) { i++; } @@ -2179,6 +2179,7 @@ R_API int r_print_format(RPrint *p, ut64 seek, const ut8* b, const int len, } bool noline = false; + int oi = i; if (isptr == NULLPTR) { if (MUSTSEEJSON) { p->cb_printf ("\"NULL\"}", tmp, seek + i); @@ -2461,6 +2462,13 @@ R_API int r_print_format(RPrint *p, ut64 seek, const ut8* b, const int len, if (mode & R_PRINT_DOT) { p->cb_printf ("}"); } + if (mode & R_PRINT_SEEFLAGS && isptr != NULLPTR) { + int sz = i - oi; + if (sz > 1) { + p->cb_printf ("fl %d @ 0x%08"PFMT64x"\n", sz, seeki); + p->cb_printf ("Cd %d @ 0x%08"PFMT64x"\n", sz, seeki); + } + } if (viewflags && p->offname) { const char *s = p->offname (p->user, seeki); if (s) {