summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2006-08-28 09:58:03 -0700
committerSteve Reinhardt <stever@eecs.umich.edu>2006-08-28 09:58:03 -0700
commit55bde23071c0bf78b6e5c5a1a5adc0d41dabe4e7 (patch)
tree06449f2a71f6884377d6a198f352470290262b5e /src
parent98e71d9ba6a97032557b33afd92920c7b46aa8b8 (diff)
downloadgem5-55bde23071c0bf78b6e5c5a1a5adc0d41dabe4e7.tar.xz
Fix remote gdb buffer overflow.
--HG-- extra : convert_revision : e5e5206bdd48120cebcb1e339b1dab2e10f4b6cf
Diffstat (limited to 'src')
-rw-r--r--src/base/remote_gdb.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index 0d3b73b1e..e4efa31e3 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -796,7 +796,6 @@ RemoteGDB::trap(int type)
size_t datalen, len;
char data[KGDB_BUFLEN + 1];
char buffer[sizeof(gdbregs) * 2 + 256];
- char temp[KGDB_BUFLEN];
const char *p;
char command, subcmd;
string var;
@@ -904,10 +903,14 @@ RemoteGDB::trap(int type)
}
if (read(val, (size_t)len, (char *)buffer)) {
- mem2hex(temp, buffer, len);
- send(temp);
+ // variable length array would be nice, but C++ doesn't
+ // officially support those...
+ char *temp = new char[2*len+1];
+ mem2hex(temp, buffer, len);
+ send(temp);
+ delete [] temp;
} else {
- send("E05");
+ send("E05");
}
continue;