From 69e7b3df281abea6155eddf86bd79cf2f898719b Mon Sep 17 00:00:00 2001 From: pancake Date: Tue, 14 Jun 2016 02:44:52 +0200 Subject: [PATCH] Fix UAF in bin.psxexe --- libr/bin/p/bin_psxexe.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/libr/bin/p/bin_psxexe.c b/libr/bin/p/bin_psxexe.c index 8cab842d93..1d3a2f4b4e 100644 --- a/libr/bin/p/bin_psxexe.c +++ b/libr/bin/p/bin_psxexe.c @@ -1,3 +1,5 @@ +/* radare - LGPL - Copyright 2015-2016 - Dax89, pancake */ + #include #include #include @@ -12,16 +14,16 @@ static void* load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, } static int check_bytes(const ut8 *buf, ut64 length) { - if (!buf || (length < PSXEXE_ID_LEN)) - return R_FALSE; - + if (!buf || (length < PSXEXE_ID_LEN)) { + return false; + } return !memcmp (buf, PSXEXE_ID, PSXEXE_ID_LEN); } static int check(RBinFile *arch) { - if (!arch || !arch->buf) + if (!arch || !arch->buf) { return false; - + } return check_bytes (r_buf_buffer (arch->buf), r_buf_size (arch->buf)); } @@ -87,13 +89,15 @@ static RList* entries(RBinFile* arch) { if (!(ret = r_list_new ())) return NULL; - if(!(addr = R_NEW0 (RBinAddr))) - return ret; + if(!(addr = R_NEW0 (RBinAddr))) { + r_list_free (ret); + return NULL; + } if (r_buf_fread_at (arch->buf, 0, (ut8*)&psxheader, "8c17i", 1) < sizeof (psxexe_header)) { - eprintf("Truncated Header\n"); - r_list_free(ret); - return ret; + eprintf ("Truncated Header\n"); + r_list_free (ret); + return NULL; } addr->paddr = (psxheader.pc0 - psxheader.t_addr) + PSXEXE_TEXTSECTION_OFFSET;