示例#1
0
文件: buf.c 项目: ericfode/radare2
R_API void r_buf_deinit(RBuffer *b) {
	if (b->mmap) {
		r_file_mmap_free (b->mmap);
		b->mmap = NULL;
	} else {
		free (b->buf);
	}
}
示例#2
0
文件: buf.c 项目: 8500616886/radare2
R_API void r_buf_deinit(RBuffer *b) {
	if (b->sparse) {
		r_list_free (b->sparse);
		b->sparse = NULL;
	}
	if (b->mmap) {
		r_file_mmap_free (b->mmap);
		b->mmap = NULL;
	} else free (b->buf);
}
示例#3
0
static int check(RBin *bin) {
	ut8 *h, buf[4];
	int off, ret = false;
	RMmap *m = r_file_mmap (bin->file, false, 0);
	if (!m || !m->buf) {
		r_file_mmap_free (m);
		return false;
	}
	h = m->buf;
	if (m->len >= 0x300 && !memcmp (h, "\xca\xfe\xba\xbe", 4)) {
		// XXX assuming BE
		off = r_read_at_be32 (h, 4 * sizeof (int));
		if (off > 0 && off < m->len) {
			memcpy (buf, h + off, 4);
			if (!memcmp (buf, "\xce\xfa\xed\xfe", 4) ||
				!memcmp (buf, "\xfe\xed\xfa\xce", 4) ||
				!memcmp (buf, "\xfe\xed\xfa\xcf", 4) ||
				!memcmp (buf, "\xcf\xfa\xed\xfe", 4))
				ret = true;
		}
	}
	r_file_mmap_free (m);
	return ret;
}
示例#4
0
static int check(RBin *bin) {
	ut8 *h, buf[4];
	int off, ret = R_FALSE;
	RMmap *m = r_file_mmap (bin->file, R_FALSE, 0);
	if (!m || !m->buf) {
		r_file_mmap_free (m);
		return R_FALSE;
	}
	h = m->buf;
	if (m->len>=0x300 && !memcmp (h, "\xca\xfe\xba\xbe", 4)) {
		memcpy (&off, h+4*sizeof (int), sizeof (int));
		r_mem_copyendian ((ut8*)&off, (ut8*)&off, sizeof(int), !LIL_ENDIAN);
		if (off > 0 && off < m->len) {
			memcpy (buf, h+off, 4);
			if (!memcmp (buf, "\xce\xfa\xed\xfe", 4) ||
				!memcmp (buf, "\xfe\xed\xfa\xce", 4) ||
				!memcmp (buf, "\xfe\xed\xfa\xcf", 4) ||
				!memcmp (buf, "\xcf\xfa\xed\xfe", 4))
				ret = R_TRUE;
		}
	}
	r_file_mmap_free (m);
	return ret;
}
示例#5
0
文件: buf.c 项目: P4N74/radare2
R_API void r_buf_deinit(RBuffer *b) {
	if (!b) return;
	if (b->fd != -1) {
		r_sandbox_close (b->fd);
		b->fd = -1;
		return;
	}
	if (b->sparse) {
		r_list_free (b->sparse);
		b->sparse = NULL;
	}
	if (b->mmap) {
		r_file_mmap_free (b->mmap);
		b->mmap = NULL;
	} else R_FREE (b->buf);
}