Skip to content

Instantly share code, notes, and snippets.

@theorbtwo
Created October 3, 2017 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theorbtwo/d98ccb31f7a47b6b2bd72024a27ca607 to your computer and use it in GitHub Desktop.
Save theorbtwo/d98ccb31f7a47b6b2bd72024a27ca607 to your computer and use it in GitHub Desktop.
commit 6c0edea89a5e98ec929f1431861e3f1df1f81e77
Author: James Mastros <james@mastros.biz>
Date: Mon Sep 18 23:26:21 2017 +0000
In gdb_get_target_description_chunk, only allocate a buffer as large as needed at EOF.
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 483e551..8ebf0e7 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -2215,8 +2215,11 @@ static int gdb_get_target_description_chunk(struct target *target, struct target
if (length < (tdesc_length - offset))
transfer_type = 'm';
- else
- transfer_type = 'l';
+ else {
+ transfer_type = 'l';
+ length = tdesc_length - offset;
+ }
+
*chunk = malloc(length + 2);
if (*chunk == NULL) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment