Fix segfault and add warning

This commit is contained in:
GustavoLCR 2019-01-11 03:20:14 -03:00 committed by radare
parent d83fa5c45d
commit 56dd308d74
2 changed files with 6 additions and 3 deletions

View File

@ -1232,6 +1232,10 @@ R_API RBuffer *r_bin_package(RBin *bin, const char *type, const char *file, RLis
ut32 num;
ut8 *num8 = (ut8*)#
RBuffer *buf = r_buf_new_file (file, true);
if (!buf) {
eprintf ("Cannot open file %s - Permission Denied.\n", file);
return NULL;
}
r_buf_write_at (buf, 0, (const ut8*)"\xca\xfe\xba\xbe", 4);
int count = r_list_length (files);

View File

@ -786,10 +786,9 @@ R_API int r_buf_fread_at (RBuffer *b, ut64 addr, ut8 *buf, const char *fmt, int
//ret 0 or -1 if failed; ret copied length if success
R_API int r_buf_write_at(RBuffer *b, ut64 addr, const ut8 *buf, int len) {
r_return_val_if_fail (b && buf && len > 0, 0);
RIOBind *iob = b->iob;
if (!b || !buf || len < 1) {
return 0;
}
ut64 start = addr - b->base + b->offset;
ut64 effective_size = r_buf_size (b);
int real_len = len;