diff --git a/libr/core/core.c b/libr/core/core.c index 0a3e170de2..c80c04b1b9 100644 --- a/libr/core/core.c +++ b/libr/core/core.c @@ -89,6 +89,11 @@ static int core_cmd_callback (void *user, const char *cmd) { return r_core_cmd0 (core, cmd); } +static char *core_cmdstr_callback (void *user, const char *cmd) { + RCore *core = (RCore *)user; + return r_core_cmd_str (core, cmd); +} + static ut64 getref (RCore *core, int n, char t, int type) { RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset, 0); RListIter *iter; @@ -884,7 +889,8 @@ R_API int r_core_init(RCore *core) { core->io = r_io_new (); core->io->ff = 1; core->io->user = (void *)core; - core->io->core_cmd_cb = core_cmd_callback; + core->io->cb_core_cmd = core_cmd_callback; + core->io->cb_core_cmdstr = core_cmdstr_callback; core->sign = r_sign_new (); core->search = r_search_new (R_SEARCH_KEYWORD); r_io_undo_enable (core->io, 1, 0); // TODO: configurable via eval diff --git a/libr/core/graph.c b/libr/core/graph.c index 55a5355342..bf8648d88c 100644 --- a/libr/core/graph.c +++ b/libr/core/graph.c @@ -874,8 +874,8 @@ R_API int r_core_visual_graph(RCore *core, RAnalFunction *_fcn) { " TAB - select previous node\n" " t/f - follow true/false edges\n" " e - toggle edge-lines style (diagonal/square)\n" - " n - toggle mini-graph\n" " O - toggle disasm mode\n" + " p - toggle mini-graph\n" " u - select previous node\n" " V - toggle basicblock / call graphs\n" " x/X - jump to xref/ref\n" @@ -957,7 +957,7 @@ R_API int r_core_visual_graph(RCore *core, RAnalFunction *_fcn) { case 'e': can->linemode = !!!can->linemode; break; - case 'n': + case 'p': graph_toggle_small_nodes(g); break; case 'u': diff --git a/libr/include/r_io.h b/libr/include/r_io.h index 3c098c5e44..3719ba146e 100644 --- a/libr/include/r_io.h +++ b/libr/include/r_io.h @@ -140,14 +140,15 @@ typedef struct r_io_t { RList *files; RList *cache; int zeromap; - //XXX: Need by rap - void *user; - int (*core_cmd_cb)(void *user, const char *str); RCache *buffer; int buffer_enabled; int ff; int autofd; char *runprofile; + /* Core Callbacks (used by rap) */ + void *user; + int (*cb_core_cmd)(void *user, const char *str); + char* (*cb_core_cmdstr)(void *user, const char *str); } RIO; typedef struct r_io_plugin_t { diff --git a/libr/io/io.c b/libr/io/io.c index 4bb19ea526..92073f2f69 100644 --- a/libr/io/io.c +++ b/libr/io/io.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2008-2014 - pancake */ +/* radare - LGPL - Copyright 2008-2015 - pancake */ #include "r_io.h" #include "r_util.h" @@ -931,6 +931,9 @@ static ut8 * r_io_desc_read (RIO *io, RIODesc * desc, ut64 *out_sz) { off = io->off; if (*out_sz == UT64_MAX) return buf; + if (*out_sz > 0xffffff) { + return buf; + } buf = malloc (*out_sz); @@ -938,7 +941,7 @@ static ut8 * r_io_desc_read (RIO *io, RIODesc * desc, ut64 *out_sz) { if (!buf || !desc->plugin->read (io, desc, buf, *out_sz)) { free (buf); io->off = off; - return R_FALSE; + return NULL; } } io->off = off; diff --git a/libr/io/p/io_rap.c b/libr/io/p/io_rap.c index 15ef1bf735..42ac950a4d 100644 --- a/libr/io/p/io_rap.c +++ b/libr/io/p/io_rap.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2011-2014 - pancake */ +/* radare - LGPL - Copyright 2011-2015 - pancake */ // TODO: implement the rap API in r_socket ? #include "r_io.h" @@ -269,9 +269,44 @@ static int rap__system(RIO *io, RIODesc *fd, const char *command) { r_socket_write (s, buf, i+5); r_socket_flush (s); + /* read reverse cmds */ + for (;;) { + ret = r_socket_read_block (s, buf, 1); + if (ret != 1) { + return -1; + } + /* system back in the middle */ + /* TODO: all pkt handlers should check for reverse queries */ + if (buf[0] == RMT_SYSTEM) { + char *res, *str; + ut32 reslen = 0, cmdlen = 0; + // run io->cmdstr + // return back the string + buf[0] |= RMT_REPLY; + ret = r_socket_read_block (s, buf+1, 4); + r_mem_copyendian ((ut8*)&cmdlen, buf+1, 4, ENDIAN); + if (cmdlen+1==0) // check overflow + cmdlen = 0; + str = calloc (1, cmdlen+1); + ret = r_socket_read_block (s, (ut8*)str, cmdlen); + //eprintf ("RUN CMD(%s)\n", str); + res = io->cb_core_cmdstr (io->user, str); + reslen = strlen (res); + free (str); + r_mem_copyendian ((ut8*)buf+1, (const ut8*)&reslen, + sizeof(ut32), ENDIAN); + free (res); + memcpy (buf+5, res, reslen); + r_socket_write (s, buf, 5+reslen); + r_socket_flush (s); + } else { + break; + } + } + // read - ret = r_socket_read_block (s, buf, 5); - if (ret != 5) + ret = r_socket_read_block (s, buf+1, 4); + if (ret != 4) return -1; if (buf[0] != (op | RMT_REPLY)) { eprintf ("Unexpected system reply\n"); @@ -280,6 +315,10 @@ static int rap__system(RIO *io, RIODesc *fd, const char *command) { r_mem_copyendian ((ut8*)&i, buf+1, 4, ENDIAN); ret = 0; + if (i>0xffff) { + eprintf ("Invalid length\n"); + return -1; + } ptr = (char *)malloc (i+1); if (ptr) { int ir; diff --git a/media/images/r2emoji.png b/media/images/r2emoji.png new file mode 100644 index 0000000000..a6cc6eb3b0 Binary files /dev/null and b/media/images/r2emoji.png differ diff --git a/media/images/r2sticker.png b/media/images/r2sticker.png new file mode 100644 index 0000000000..cb175e451c Binary files /dev/null and b/media/images/r2sticker.png differ