Fix UAF in bin.psxexe
This commit is contained in:
parent
59f94c63aa
commit
69e7b3df28
1 changed files with 14 additions and 10 deletions
|
|
@ -1,3 +1,5 @@
|
|||
/* radare - LGPL - Copyright 2015-2016 - Dax89, pancake */
|
||||
|
||||
#include <string.h>
|
||||
#include <r_types.h>
|
||||
#include <r_lib.h>
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue