don't let hexify call strlen
authorTom Tromey <tromey@redhat.com>
Sun, 19 Jan 2014 02:25:57 +0000 (19:25 -0700)
committerTom Tromey <tromey@redhat.com>
Wed, 12 Feb 2014 16:59:16 +0000 (09:59 -0700)
hexify had the same issue as bin2hex; and the fix is the same.

2014-02-12  Tom Tromey  <tromey@redhat.com>

* common/rsp-low.c (hexify): Never take strlen of argument.

2014-02-12  Tom Tromey  <tromey@redhat.com>

* remote-utils.c (monitor_output): Pass explicit length to
hexify.

gdb/ChangeLog
gdb/common/rsp-low.c
gdb/gdbserver/ChangeLog
gdb/gdbserver/remote-utils.c

index e1dfbbb623952a79b1c7654c90860987d0df11f3..e8521c9ac171e01b14a4603064f23ba0dac676fe 100644 (file)
@@ -1,3 +1,7 @@
+2014-02-12  Tom Tromey  <tromey@redhat.com>
+
+       * common/rsp-low.c (hexify): Never take strlen of argument.
+
 2014-02-12  Tom Tromey  <tromey@redhat.com>
 
        * common/rsp-low.c (bin2hex): Never take strlen of argument.
index 7f0445cb2504886cdeac2209deeaedef5f478e93..fd6f56345c6a3cb414bfcb7ee04a3c71dfb25874 100644 (file)
@@ -177,10 +177,6 @@ hexify (char *hex, const char *bin, int count)
 {
   int i;
 
-  /* May use a length, or a nul-terminated string as input. */
-  if (count == 0)
-    count = strlen (bin);
-
   for (i = 0; i < count; i++)
     {
       *hex++ = tohex ((*bin >> 4) & 0xf);
index 7bf4a0fbca5e70543885fd8abd97dadf9247e904..35303dfc05b49c823b1cddf5556e3413cac489aa 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-12  Tom Tromey  <tromey@redhat.com>
+
+       * remote-utils.c (monitor_output): Pass explicit length to
+       hexify.
+
 2014-02-12  Tom Tromey  <tromey@redhat.com>
 
        * tracepoint.c: Include rsp-low.h.
index b83517535d0af1ecbe1914bfb09c25cc97ecf8e3..8fd7c4a01ecabb6a137b0495ffdff7f6df2c8410 100644 (file)
@@ -1558,10 +1558,11 @@ relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
 void
 monitor_output (const char *msg)
 {
-  char *buf = xmalloc (strlen (msg) * 2 + 2);
+  int len = strlen (msg);
+  char *buf = xmalloc (len * 2 + 2);
 
   buf[0] = 'O';
-  hexify (buf + 1, msg, 0);
+  hexify (buf + 1, msg, len);
 
   putpkt (buf);
   free (buf);
This page took 0.045509 seconds and 4 git commands to generate.