public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [COMMITTED PATCH] Fix off-by-one error in make_hex_string.
@ 2014-12-13 22:10 Doug Evans
  2014-12-13 22:23 ` Joel Brobecker
  0 siblings, 1 reply; 4+ messages in thread
From: Doug Evans @ 2014-12-13 22:10 UTC (permalink / raw)
  To: gdb-patches, brobecker

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;
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [COMMITTED PATCH] Fix off-by-one error in make_hex_string.
  2014-12-13 22:10 [COMMITTED PATCH] Fix off-by-one error in make_hex_string Doug Evans
@ 2014-12-13 22:23 ` Joel Brobecker
  2014-12-13 22:26   ` Doug Evans
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Brobecker @ 2014-12-13 22:23 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

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

Grrr, thank you! I don't understand why I didn't get that error,
though, as I ran the testsuite. That's weird...

-- 
Joel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [COMMITTED PATCH] Fix off-by-one error in make_hex_string.
  2014-12-13 22:23 ` Joel Brobecker
@ 2014-12-13 22:26   ` Doug Evans
  2014-12-13 23:33     ` Joel Brobecker
  0 siblings, 1 reply; 4+ messages in thread
From: Doug Evans @ 2014-12-13 22:26 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Sat, Dec 13, 2014 at 2:23 PM, Joel Brobecker <brobecker@adacore.com> wrote:
>> python print (objfile.build_id)
>> ../../to-push/gdb/common/common-utils.c:139: internal-error: xsnprintf: Assertion `ret < size' failed.
>
> Grrr, thank you! I don't understand why I didn't get that error,
> though, as I ran the testsuite. That's weird...

I can imagine it's because the toolchain you used didn't add a build id.
Just a guess though.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [COMMITTED PATCH] Fix off-by-one error in make_hex_string.
  2014-12-13 22:26   ` Doug Evans
@ 2014-12-13 23:33     ` Joel Brobecker
  0 siblings, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2014-12-13 23:33 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

> I can imagine it's because the toolchain you used didn't add a build id.
> Just a guess though.

Yes, that's probably it. We need a unit test framework... ;-)

-- 
Joel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-12-13 23:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-13 22:10 [COMMITTED PATCH] Fix off-by-one error in make_hex_string Doug Evans
2014-12-13 22:23 ` Joel Brobecker
2014-12-13 22:26   ` Doug Evans
2014-12-13 23:33     ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).