From 10b4b5546cb2d0b8f963548d5aaa8fb3e3b2fee5 Mon Sep 17 00:00:00 2001 From: pancake Date: Tue, 14 Aug 2012 01:25:50 +0200 Subject: [PATCH] Fix resize command and more make race conditions --- libr/asm/Makefile | 3 ++- libr/cmd/Makefile | 3 ++- libr/core/cmd.c | 2 +- libr/core/cmd_write.c | 3 +++ libr/core/io.c | 1 + libr/crypto/Makefile | 3 ++- libr/egg/Makefile | 4 ++-- libr/fs/Makefile | 3 ++- libr/io/io.c | 9 ++++----- 9 files changed, 19 insertions(+), 12 deletions(-) diff --git a/libr/asm/Makefile b/libr/asm/Makefile index 79b2570065..f486abb3dd 100644 --- a/libr/asm/Makefile +++ b/libr/asm/Makefile @@ -4,7 +4,8 @@ CFLAGS+=-DCORELIB -Iarch/include -Iarch -I../../shlr include ../config.mk -foo: pre ${LIBSO} ${LIBAR} plugins +foo: + @for a in pre ${LIBSO} ${LIBAR} plugins ; do ${MAKE} $$a ; done include ${STATIC_ASM_PLUGINS} STATIC_OBJS=$(subst ..,p/..,$(subst asm_,p/asm_,$(STATIC_OBJ))) diff --git a/libr/cmd/Makefile b/libr/cmd/Makefile index b42e382b33..9edb5d1741 100644 --- a/libr/cmd/Makefile +++ b/libr/cmd/Makefile @@ -6,7 +6,8 @@ include ../config.mk CFLAGS+=-DCORELIB -foo: ${LIBSO} ${LIBAR} plugins +foo: + for a in ${LIBSO} ${LIBAR} plugins ; do ${MAKE} $$a ; done include ${STATIC_CMD_PLUGINS} STATIC_OBJS=$(subst ..,p/..,$(subst cmd_,p/cmd_,$(STATIC_OBJ))) diff --git a/libr/core/cmd.c b/libr/core/cmd.c index 427de8f3de..be8cd94143 100644 --- a/libr/core/cmd.c +++ b/libr/core/cmd.c @@ -282,7 +282,7 @@ static int cmd_resize(void *data, const char *input) { " r+num insert num bytes, move following data up\n"); return R_TRUE; default: - newsize = r_num_math (core->num, input+1); + newsize = r_num_math (core->num, input); } grow = (newsize > oldsize); diff --git a/libr/core/cmd_write.c b/libr/core/cmd_write.c index 855ed66d43..56b9a52339 100644 --- a/libr/core/cmd_write.c +++ b/libr/core/cmd_write.c @@ -126,8 +126,11 @@ static int cmd_write(void *data, const char *input) { case ' ': /* write string */ len = r_str_escape (str); + r_core_write_at (core, core->offset, str, len); +#if 0 r_io_set_fd (core->io, core->file->fd); r_io_write_at (core->io, core->offset, (const ut8*)str, len); +#endif WSEEK (core, len); r_core_block_read (core, 0); break; diff --git a/libr/core/io.c b/libr/core/io.c index 289119f98b..6f004cdc6e 100644 --- a/libr/core/io.c +++ b/libr/core/io.c @@ -138,6 +138,7 @@ R_API int r_core_write_at(RCore *core, ut64 addr, const ut8 *buf, int size) { if (addr >= core->offset && addr <= core->offset+core->blocksize) r_core_block_read (core, 0); } + core->file->size = r_io_size (core->io); return (ret==-1)? R_FALSE: R_TRUE; } diff --git a/libr/crypto/Makefile b/libr/crypto/Makefile index e572ee15ed..b2aede21a7 100644 --- a/libr/crypto/Makefile +++ b/libr/crypto/Makefile @@ -4,7 +4,8 @@ CFLAGS+=-DCORELIB include ../config.mk -foo: pre libr_crypto.${EXT_SO} libr_crypto.${EXT_AR} plugins +foo: + for a in pre libr_crypto.${EXT_SO} libr_crypto.${EXT_AR} plugins ; do ${MAKE} $$a ; done include ${STATIC_CRYPTO_PLUGINS} STATIC_OBJS=$(subst ..,p/..,$(subst crypto_,p/crypto_,$(STATIC_OBJ))) diff --git a/libr/egg/Makefile b/libr/egg/Makefile index 6fc5d06c9c..604107c320 100644 --- a/libr/egg/Makefile +++ b/libr/egg/Makefile @@ -10,8 +10,8 @@ OBJ+=emit_arm.o OBJ+=emit_x64.o OBJ+=emit_trace.o -foo: ${LIBSO} ${LIBAR} - ${MAKE} all +foo: + for a in ${LIBSO} ${LIBAR} all ; do ${MAKE} $$a ; done P=p/ include ${STATIC_EGG_PLUGINS} diff --git a/libr/fs/Makefile b/libr/fs/Makefile index acfbec6557..5171890e06 100644 --- a/libr/fs/Makefile +++ b/libr/fs/Makefile @@ -8,7 +8,8 @@ LDFLAGS+=p/grub/libgrubfs.a include ../config.mk EXTRA_TARGETS=plugins -foo: pre plugins ${LIBSO} ${LIBAR} +foo: + for a in pre plugins ${LIBSO} ${LIBAR} ; do ${MAKE} $$a ; done include ${STATIC_FS_PLUGINS} STATIC_OBJS=$(subst ..,p/..,$(subst fs_,p/fs_,$(STATIC_OBJ))) diff --git a/libr/io/io.c b/libr/io/io.c index 61247cc4cd..d0e6faaf2d 100644 --- a/libr/io/io.c +++ b/libr/io/io.c @@ -144,11 +144,10 @@ R_API int r_io_set_fd(RIO *io, RIODesc *fd) { R_API int r_io_set_fdn(RIO *io, int fd) { if (fd != -1 && io->fd != NULL && fd != io->fd->fd) { RIODesc *desc = r_io_desc_get (io, fd); - if (desc) { - io->fd = desc; - io->plugin = desc->plugin; - return R_TRUE; - } + if (!desc) return R_FALSE; + io->fd = desc; + io->plugin = desc->plugin; + return R_TRUE; } return R_FALSE; }