Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <xdje42@gmail.com>
To: gdb-patches@sourceware.org, brobecker@adacore.com
Subject: [COMMITTED PATCH] Fix off-by-one error in make_hex_string.
Date: Sat, 13 Dec 2014 22:10:00 -0000	[thread overview]
Message-ID: <m3fvcji4mp.fsf@seba.sebabeach.org> (raw)

Hi.

I noticed a failure in py-objfile.exp:

python print (objfile.build_id)
../../to-push/gdb/common/common-utils.c:139: internal-error: xsnprintf: Assertion `ret < size' failed.

It's just an off-by-one error in make_hex_string.

The size argument to xsnprintf must include the trailing nul,
but the result does not include it.

2014-12-13  Doug Evans  <xdje42@gmail.com>

	* utils.c (make_hex_string): Fix off-by-one error.

diff --git a/gdb/utils.c b/gdb/utils.c
index ea2b18a..47adb67 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1124,7 +1124,7 @@ make_hex_string (const gdb_byte *data, size_t length)
 
   p = result;
   for (i = 0; i < length; ++i)
-    p += xsnprintf (p, 2, "%02x", data[i]);
+    p += xsnprintf (p, 3, "%02x", data[i]);
   *p = '\0';
   return result;
 }


             reply	other threads:[~2014-12-13 22:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-13 22:10 Doug Evans [this message]
2014-12-13 22:23 ` Joel Brobecker
2014-12-13 22:26   ` Doug Evans
2014-12-13 23:33     ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3fvcji4mp.fsf@seba.sebabeach.org \
    --to=xdje42@gmail.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox