mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 13:49:50 +00:00
Fix fatmach0 integer underflow issue
This commit is contained in:
parent
eb7deb281d
commit
0aa64c0296
@ -483,13 +483,9 @@ R_API int r_bin_load_io_at_offset_as_sz(RBin *bin, int fd, ut64 baseaddr,
|
||||
}
|
||||
}
|
||||
if (!binfile) {
|
||||
if (true) {
|
||||
binfile = r_bin_file_new_from_bytes (
|
||||
bin, fname, buf_bytes, sz, file_sz, bin->rawstr,
|
||||
baseaddr, loadaddr, fd, name, NULL, offset, true);
|
||||
} else {
|
||||
binfile = r_bin_file_new_from_fd (bin, tfd, NULL);
|
||||
}
|
||||
binfile = r_bin_file_new_from_bytes (
|
||||
bin, fname, buf_bytes, sz, file_sz, bin->rawstr,
|
||||
baseaddr, loadaddr, fd, name, NULL, offset, true);
|
||||
}
|
||||
return binfile? r_bin_file_set_cur_binfile (bin, binfile): false;
|
||||
}
|
||||
@ -1078,8 +1074,14 @@ R_API int r_bin_use_arch(RBin *bin, const char *arch, int bits, const char *name
|
||||
bin->cur->curplugin = plugin;
|
||||
}
|
||||
binfile = r_bin_file_new (bin, "-", NULL, 0, 0, 0, 999, NULL, NULL, false);
|
||||
if (!binfile) {
|
||||
return false;
|
||||
}
|
||||
// create object and set arch/bits
|
||||
obj = r_bin_object_new (binfile, plugin, 0, 0, 0, 1024);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
binfile->o = obj;
|
||||
obj->info = R_NEW0 (RBinInfo);
|
||||
obj->info->arch = strdup (arch);
|
||||
|
@ -436,7 +436,7 @@ int file_sz = 0;
|
||||
}
|
||||
if (!plugin) {
|
||||
ut8 bytes[1024];
|
||||
int sz = 1024;
|
||||
int sz = sizeof (bytes);
|
||||
r_buf_read_at (bf->buf, 0, bytes, sz);
|
||||
plugin = r_bin_get_binplugin_by_bytes (bin, bytes, sz);
|
||||
if (!plugin) {
|
||||
@ -856,7 +856,7 @@ R_API RBinFile *r_bin_file_xtr_load_bytes(RBin *bin, RBinXtrPlugin *xtr, const c
|
||||
}
|
||||
|
||||
#define LIMIT_SIZE 0
|
||||
R_API int r_bin_file_set_bytes(RBinFile *binfile, const ut8 *bytes, ut64 sz, bool steal_ptr) {
|
||||
R_API bool r_bin_file_set_bytes(RBinFile *binfile, const ut8 *bytes, ut64 sz, bool steal_ptr) {
|
||||
if (!binfile) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2017 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2018 - pancake */
|
||||
|
||||
#include <r_types.h>
|
||||
#include <r_util.h>
|
||||
|
@ -17,8 +17,8 @@ static bool checkHeader(const ut8 *h, int sz) {
|
||||
ut8 buf[4];
|
||||
if (sz >= 0x300 && !memcmp (h, "\xca\xfe\xba\xbe", 4)) {
|
||||
// XXX assuming BE
|
||||
int off = r_read_at_be32 (h, 4 * sizeof (int));
|
||||
if (off > 0 && off + h + 4 < sz) {
|
||||
ut32 off = r_read_at_be32 (h, 4 * sizeof (int));
|
||||
if (off > 0 && off + 4 < sz) {
|
||||
memcpy (buf, h + off, 4);
|
||||
if (!memcmp (buf, "\xce\xfa\xed\xfe", 4) ||
|
||||
!memcmp (buf, "\xfe\xed\xfa\xce", 4) ||
|
||||
|
@ -672,7 +672,7 @@ R_API int r_bin_file_ref(RBin *bin, RBinFile *a);
|
||||
R_API void r_bin_file_free(void /*RBinFile*/ *bf_);
|
||||
R_API RBinFile *r_bin_file_create_append(RBin *bin, const char *file, const ut8 *bytes, ut64 sz, ut64 file_sz, int rawstr, int fd, const char *xtrname, bool steal_ptr);
|
||||
R_API RBinFile *r_bin_file_xtr_load_bytes(RBin *bin, RBinXtrPlugin *xtr, const char *filename, const ut8 *bytes, ut64 sz, ut64 file_sz, ut64 baseaddr, ut64 loadaddr, int idx, int fd, int rawstr);
|
||||
R_API int r_bin_file_set_bytes(RBinFile *binfile, const ut8 *bytes, ut64 sz, bool steal_ptr);
|
||||
R_API bool r_bin_file_set_bytes(RBinFile *binfile, const ut8 *bytes, ut64 sz, bool steal_ptr);
|
||||
R_API RBinPlugin *r_bin_file_cur_plugin(RBinFile *binfile);
|
||||
|
||||
/* obj.c */
|
||||
|
Loading…
Reference in New Issue
Block a user