gdb_server: use strndup to allocate debug messages
authorSpencer Oliver <spen@spen-soft.co.uk>
Thu, 1 Dec 2011 12:48:31 +0000 (12:48 +0000)
committerSpencer Oliver <spen@spen-soft.co.uk>
Fri, 2 Dec 2011 12:26:04 +0000 (12:26 +0000)
Lets be consistent and use strndup to allocate the debug buffer.

Change-Id: I535ad270ebfeae6e09d28372ab3749c822971223
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/245
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
src/server/gdb_server.c

index 93aa8edc5d753499bb5228799d7088e34088bcb9..537513a1b6b831179ac8a405ef02d44170fa1e75 100644 (file)
@@ -44,7 +44,6 @@
 #include "rtos/rtos.h"
 #include "target/smp.h"
 
-
 /**
  * @file
  * GDB server implementation.
@@ -77,7 +76,6 @@ struct gdb_connection
        bool mem_write_error;
 };
 
-
 #if 0
 #define _DEBUG_GDB_IO_
 #endif
@@ -245,9 +243,7 @@ static int gdb_get_char_inner(struct connection *connection, int* next_char)
        }
 
 #ifdef _DEBUG_GDB_IO_
-       debug_buffer = malloc(gdb_con->buf_cnt + 1);
-       memcpy(debug_buffer, gdb_con->buffer, gdb_con->buf_cnt);
-       debug_buffer[gdb_con->buf_cnt] = 0;
+       debug_buffer = strndup(gdb_con->buffer, gdb_con->buf_cnt);
        LOG_DEBUG("received '%s'", debug_buffer);
        free(debug_buffer);
 #endif
@@ -389,9 +385,7 @@ static int gdb_put_packet_inner(struct connection *connection,
        while (1)
        {
 #ifdef _DEBUG_GDB_IO_
-               debug_buffer = malloc(len + 1);
-               memcpy(debug_buffer, buffer, len);
-               debug_buffer[len] = 0;
+               debug_buffer = strndup(buffer, len);
                LOG_DEBUG("sending packet '$%s#%2.2x'", debug_buffer, my_checksum);
                free(debug_buffer);
 #endif

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)