diff --git a/libr/core/cmd_write.c b/libr/core/cmd_write.c index aab8b52aac..b5b3855d09 100644 --- a/libr/core/cmd_write.c +++ b/libr/core/cmd_write.c @@ -697,7 +697,7 @@ static int cmd_write(void *data, const char *input) { } } else if (*str != ' ') { const char* prefix = r_config_get (core->config, "cfg.prefixdump"); - snprintf(_fn, sizeof(_fn), "%s.0x%08"PFMT64x, prefix, core->offset); + snprintf (_fn, sizeof(_fn), "%s.0x%08"PFMT64x, prefix, core->offset); filename = _fn; } else filename = str+1; tmp = strchr (str+1, ' '); diff --git a/libr/core/io.c b/libr/core/io.c index 99e3c53680..f678646165 100644 --- a/libr/core/io.c +++ b/libr/core/io.c @@ -83,15 +83,22 @@ R_API int r_core_dump(RCore *core, const char *file, ut64 addr, ut64 size, int a eprintf ("Cannot open '%s' for writing\n", file); return R_FALSE; } + /* some io backends seems to be buggy in those cases */ + if (bs > 4096) + bs = 4096; buf = malloc (bs); + if (!buf) { + eprintf ("Cannot alloc %d bytes\n", bs); + return R_FALSE; + } r_cons_break (NULL, NULL); - for (i=0; ibreaked) break; - if ((i+bs)>size) - bs = size-i; - r_io_read_at (core->io, addr+i, buf, bs); - if (fwrite (buf, bs, 1, fd) <1) { + if ((i + bs) > size) + bs = size - i; + r_io_read_at (core->io, addr + i, buf, bs); + if (fwrite (buf, bs, 1, fd) < 1) { eprintf ("write error\n"); break; }