From 277771156c5eb3d4179531c54ece7867dbfb0104 Mon Sep 17 00:00:00 2001 From: Srimanta Barua Date: Wed, 26 Jul 2017 23:50:07 +0530 Subject: [PATCH] fix gdb covs (#8036) --- libr/core/rtr.c | 46 +++++++++++++---------------------- shlr/gdb/src/gdbclient/core.c | 2 +- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/libr/core/rtr.c b/libr/core/rtr.c index 842e4b565e..a317b00de9 100644 --- a/libr/core/rtr.c +++ b/libr/core/rtr.c @@ -1211,39 +1211,27 @@ static int r_core_rtr_gdb_run(RCore *core, int launch, const char *path) { debug_msg = true; path++; } - while (*path && isspace (*path)) { - path++; - } - if (!*path) { + if (!(path = r_str_chop_ro (path)) || !*path) { eprintf ("gdbserver: Port not specified\n"); return -1; } - if (path && (p = atoi (path))) { - if (p < 0 || p > 65535) { - eprintf ("gdbserver: Invalid port: %s\n", port); - return -1; - } - snprintf (port, sizeof (port) - 1, "%d", p); - if (!(file = strchr (path, ' '))) { - eprintf ("gdbserver: File not specified\n"); - return -1; - } - while (isspace (*file)) { - file++; - } - if (!*file) { - eprintf ("gdbserver: File not specified\n"); - return -1; - } + if (!(p = atoi (path)) || p < 0 || p > 65535) { + eprintf ("gdbserver: Invalid port: %s\n", port); + return -1; } - if (file) { - args = strchr (file, ' '); - if (args) { - *args++ = '\0'; - while (isspace (*args)) { - args++; - } - } else { + snprintf (port, sizeof (port) - 1, "%d", p); + if (!(file = strchr (path, ' '))) { + eprintf ("gdbserver: File not specified\n"); + return -1; + } + if (!(file = r_str_chop_ro (file)) || !*file) { + eprintf ("gdbserver: File not specified\n"); + return -1; + } + args = strchr (file, ' '); + if (args) { + *args++ = '\0'; + if (!(args = r_str_chop_ro (args))) { args = ""; } } else { diff --git a/shlr/gdb/src/gdbclient/core.c b/shlr/gdb/src/gdbclient/core.c index b6178ae917..a01d45e1ef 100644 --- a/shlr/gdb/src/gdbclient/core.c +++ b/shlr/gdb/src/gdbclient/core.c @@ -1046,7 +1046,7 @@ int gdbr_send_qRcmd(libgdbr_t *g, const char *cmd) { if (!(buf = calloc (len, sizeof (char)))) { return -1; } - strncpy (buf, "qRcmd,", 6); + strcpy (buf, "qRcmd,"); pack_hex (cmd, strlen (cmd), buf + 6); if (send_msg (g, buf) < 0) { free (buf);