aboutsummaryrefslogtreecommitdiff
path: root/gdb/ser-ocd.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/ser-ocd.c')
-rw-r--r--gdb/ser-ocd.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/gdb/ser-ocd.c b/gdb/ser-ocd.c
index 4008a87..08239bb 100644
--- a/gdb/ser-ocd.c
+++ b/gdb/ser-ocd.c
@@ -81,21 +81,26 @@ ocd_raw (scb)
/* Always in raw mode */
}
-/* We need a buffer to store responses from the Wigglers.dll */
-#define WIGGLER_BUFF_SIZE 512
-unsigned char from_wiggler_buffer[WIGGLER_BUFF_SIZE];
-unsigned char * wiggler_buffer_ptr; /* curr spot in buffer */
-
static void
ocd_readremote ()
{
}
+/* We need a buffer to store responses from the Wigglers.dll */
+#define WIGGLER_BUFF_SIZE 512
+unsigned char from_wiggler_buffer[WIGGLER_BUFF_SIZE];
+unsigned char * wiggler_buffer_ptr; /* curr spot in buffer */
+
static int
ocd_readchar (scb, timeout)
serial_t scb;
int timeout;
{
+ /* Catch attempts at reading past the end of the buffer */
+ if (wiggler_buffer_ptr >
+ (from_wiggler_buffer + (sizeof (char *) * WIGGLER_BUFF_SIZE)))
+ error ("ocd_readchar asked to read past the end of the buffer!");
+
return (int) *wiggler_buffer_ptr++; /* return curr char and increment ptr */
}