From 26e9c4feacd5ba1e9692f859826ae33489e62546 Mon Sep 17 00:00:00 2001 From: pancake Date: Wed, 16 Nov 2016 03:02:50 +0100 Subject: [PATCH] Only scr.linesleep when in sandbox-free interactive --- libr/cons/cons.c | 38 +++++++++++++++++++++----------------- libr/core/cmd_anal.c | 20 +++++++++++--------- libr/syscall/syscall.c | 4 +--- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/libr/cons/cons.c b/libr/cons/cons.c index 4513daa995..7b190010e1 100644 --- a/libr/cons/cons.c +++ b/libr/cons/cons.c @@ -539,25 +539,29 @@ R_API void r_cons_flush() { if (I.is_html) { r_cons_html_print (I.buffer); } else { - if (I.linesleep > 0 && I.linesleep < 1000) { - int i = 0; - int pagesize = R_MAX (1, I.pagesize); - char *ptr = I.buffer; - char *nl = strchr (ptr, '\n'); - int len = I.buffer_len; - I.buffer[I.buffer_len] = 0; - r_cons_break (NULL, NULL); - while (nl && !r_cons_is_breaked ()) { - r_cons_write (ptr, nl - ptr + 1); - if (!(i % pagesize)) { - r_sys_usleep (I.linesleep * 1000); + if (I.is_interactive && !r_sandbox_enable (false)) { + if (I.linesleep > 0 && I.linesleep < 1000) { + int i = 0; + int pagesize = R_MAX (1, I.pagesize); + char *ptr = I.buffer; + char *nl = strchr (ptr, '\n'); + int len = I.buffer_len; + I.buffer[I.buffer_len] = 0; + r_cons_break (NULL, NULL); + while (nl && !r_cons_is_breaked ()) { + r_cons_write (ptr, nl - ptr + 1); + if (!(i % pagesize)) { + r_sys_usleep (I.linesleep * 1000); + } + ptr = nl + 1; + nl = strchr (ptr, '\n'); + i++; } - ptr = nl + 1; - nl = strchr (ptr, '\n'); - i++; + r_cons_write (ptr, I.buffer + len - ptr); + r_cons_break_end (); + } else { + r_cons_write (I.buffer, I.buffer_len); } - r_cons_write (ptr, I.buffer + len - ptr); - r_cons_break_end (); } else { r_cons_write (I.buffer, I.buffer_len); } diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index 4d2e1f27ab..0f960896bc 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -3338,15 +3338,17 @@ static void cmd_anal_syscall(RCore *core, const char *input) { else eprintf ("Unknown syscall number\n"); } else { n = r_syscall_get_num (core->anal->syscall, input + 2); - if (n != -1) + if (n != -1) { r_cons_printf ("%d\n", n); - else eprintf ("Unknown syscall name\n"); + } else { + eprintf ("Unknown syscall name\n"); + } } } else { list = r_syscall_list (core->anal->syscall); r_list_foreach (list, iter, si) { - r_cons_printf ("%s = 0x%02x.%d\n", - si->name, si->swi, si->num); + r_cons_printf ("%s = 0x%02x.%u\n", + si->name, (ut32)si->swi, (ut32)si->num); } r_list_free (list); } @@ -3395,11 +3397,11 @@ static void anal_axg (RCore *core, const char *input, int level, Sdb *db) { if (input && *input) { addr = r_num_math (core->num, input); } - int spaces = (level+1) * 2; - if (spaces > sizeof (pre)-4) { - spaces = sizeof(pre)-4; + int spaces = (level + 1) * 2; + if (spaces > sizeof (pre) - 4) { + spaces = sizeof (pre) - 4; } - memset (pre, ' ', sizeof(pre)); + memset (pre, ' ', sizeof (pre)); strcpy (pre+spaces, "- "); xrefs = r_anal_xrefs_get (core->anal, addr); @@ -3408,7 +3410,7 @@ static void anal_axg (RCore *core, const char *input, int level, Sdb *db) { if (fcn) { //if (sdb_add (db, fcn->name, "1", 0)) { r_cons_printf ("%s0x%08"PFMT64x" fcn 0x%08"PFMT64x" %s\n", - pre+2, addr, fcn->addr, fcn->name); + pre + 2, addr, fcn->addr, fcn->name); //} } else { //snprintf (arg, sizeof (arg), "0x%08"PFMT64x, addr); diff --git a/libr/syscall/syscall.c b/libr/syscall/syscall.c index fca05ad389..3c2b0c8616 100644 --- a/libr/syscall/syscall.c +++ b/libr/syscall/syscall.c @@ -167,7 +167,6 @@ R_API int r_syscall_get_swi(RSyscall *s) { R_API RSyscallItem *r_syscall_get(RSyscall *s, int num, int swi) { const char *ret, *ret2, *key; - RSyscallItem *si; if (!s || !s->db) { eprintf ("Syscall database not loaded\n"); return NULL; @@ -186,8 +185,7 @@ R_API RSyscallItem *r_syscall_get(RSyscall *s, int num, int swi) { if (!ret2) { return NULL; } - si = r_syscall_item_new_from_string (ret, ret2); - return si; + return r_syscall_item_new_from_string (ret, ret2); } R_API int r_syscall_get_num(RSyscall *s, const char *str) {