diff --git a/libr/core/cmd_write.c b/libr/core/cmd_write.c index c900468b54..45aa4c4808 100644 --- a/libr/core/cmd_write.c +++ b/libr/core/cmd_write.c @@ -130,7 +130,9 @@ static void cmd_write_value (RCore *core, const char *input) { case '8': type = 8; break; } off = r_num_math (core->num, input+2); - r_io_use_desc (core->io, core->file->desc); + if (core->file) { + r_io_use_desc (core->io, core->file->desc); + } r_io_seek (core->io, core->offset, R_IO_SEEK_SET); if (type == 0) type = (off&UT64_32U)? 8: 4; @@ -183,6 +185,7 @@ static int cmd_write(void *data, const char *input) { "waf"," file","assemble file and write bytes", "wA"," r 0","alter/modify opcode at current seek (see wA?)", "wb"," 010203","fill current block with cyclic hexpairs", + "wB","[-]0xVALUE","set or unset bits with given value", "wc","","list all write changes", "wc","[ir*?]","write cache undo/commit/reset/list (io.cache)", "wd"," [off] [n]","duplicate N bytes from offset at current seek (memcpy) (see y?)", diff --git a/libr/io/io.c b/libr/io/io.c index d7e222371b..c573a6894a 100644 --- a/libr/io/io.c +++ b/libr/io/io.c @@ -653,16 +653,21 @@ R_API int r_io_write(RIO *io, const ut8 *buf, int len) { ret = -1; } } else { - ret = write (io->desc->fd, buf, len); + if (io->desc) { + ret = write (io->desc->fd, buf, len); + } else ret = -1; } if (ret == -1) { if (io->cached != 2) { - eprintf ("r_io_write: cannot write on fd %d\n", io->desc->fd); + eprintf ("r_io_write: cannot write on fd %d\n", + io->desc? io->desc->fd: -1); r_io_cache_invalidate (io, io->off, io->off+1); } } else { - r_io_map_write_update (io, io->desc->fd, io->off, ret); - io->off += ret; + if (io->desc) { + r_io_map_write_update (io, io->desc->fd, io->off, ret); + io->off += ret; + } } free (data); return ret; diff --git a/sys/duktape.sh b/sys/duktape.sh index 3d923f96f7..25ae25a57f 100755 --- a/sys/duktape.sh +++ b/sys/duktape.sh @@ -5,6 +5,10 @@ cd `dirname $PWD/$0` ./clone-r2-bindings.sh cd .. +# workaround for osx +if [ -f /usr/lib/pkgconfig/r_util.pc ]; then + export PKG_CONFIG_PATH=/usr/lib/pkgconfig +fi [ -z "${PREFIX}" ] && PREFIX=/usr ID=`id -u` [ -n "${NOSUDO}" ] && SUDO= @@ -12,11 +16,11 @@ ID=`id -u` export DESTDIR cd radare2-bindings -./configure --prefix=/usr --enable=duktape +./configure --prefix=/usr --enable=duktape || exit 1 cd libr/lang/p make clean -make -rm ~/.config/radare2/plugins/lang_duktape.* +make || exit 1 +rm -f ~/.config/radare2/plugins/lang_duktape.* if [ "$1" != '--no-install' ]; then if [ "$ID" = 0 ]; then ${SUDO} make install DESTDIR=${DESTDIR}