CID 1216466 Dereference before null check /libr/bin/p/bin_dex.c

This commit is contained in:
David Kreuter 2015-07-14 13:23:23 +02:00 committed by pancake
parent c843e22843
commit fecb914de8
2 changed files with 17 additions and 14 deletions

View File

@ -733,15 +733,18 @@ static int already_entry (RList *entries, ut64 vaddr) {
static RList* entries(RBinFile *arch) {
RListIter *iter;
RBinDexObj *bin = (RBinDexObj*) arch->o->bin_obj;
RList *ret = r_list_new ();
RBinAddr *ptr = R_NEW0 (RBinAddr);
RBinDexObj *bin;
RList *ret;
RBinAddr *ptr;
RBinSymbol *m;
if (!arch || !bin) {
free (ret);
free (ptr);
if (!arch || !arch->o || !arch->o->bin_obj)
return NULL;
}
bin = (RBinDexObj*) arch->o->bin_obj;
ret = r_list_new ();
ptr = R_NEW0 (RBinAddr);
if (!bin->methods_list) {
dex_loadcode (arch, bin);
}

View File

@ -21,19 +21,19 @@
static void updateAddr(const ut8 *buf, int i, int endian, ut64 *addr, ut64 *addr64) {
if (addr) {
if (endian)
*addr = ((ut32)*(buf+i))<<24)
| ((ut32)*(buf+i+1))<<16)
| ((ut32)*(buf+i+2))<<8)
| ((ut32)*(buf+i+3)));
*addr = ((ut32)(*(buf+i))<<24)
| ((ut32)(*(buf+i+1))<<16)
| ((ut32)(*(buf+i+2))<<8)
| ((ut32)(*(buf+i+3)));
else
*addr = ((ut32)*(buf+i+3))<<24)
*addr = ((ut32)(*(buf+i+3))<<24)
| ((ut32)(*(buf+i+2))<<16)
| ((ut32)(*(buf+i+1))<<8)
| ((ut32)(*(buf+i)));
}
if (addr64) {
if (endian)
*addr64 = (((ut64)(*(buf+i))<<56))
*addr64 = ((ut64)(*(buf+i))<<56)
| ((ut64)(*(buf+i+1))<<48)
| ((ut64)(*(buf+i+2))<<40)
| ((ut64)(*(buf+i+3))<<32)
@ -42,7 +42,7 @@ static void updateAddr(const ut8 *buf, int i, int endian, ut64 *addr, ut64 *addr
| ((ut64)(*(buf+i+6))<<8)
| ((ut64)(*(buf+i+7)));
else
*addr64 =(((ut64)(*(buf+i+7))<<56))
*addr64 = ((ut64)(*(buf+i+7))<<56)
| ((ut64)(*(buf+i+6))<<48)
| ((ut64)(*(buf+i+5))<<40)
| ((ut64)(*(buf+i+4))<<32)