This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] readelf.c: Assume the right size of an array


In `register_info' we're taking the size of argument `name', which is wrong,
since we get just the size of a pointer, not size of the array.  This patch
fixes it.  Tested on x86_64 using trunk gcc.

I have trouble with git+ssh (Permission denied (publickey), although I have
my right pub key on fedorahosted.com), so I'd not be able to push this in case
it's fine.  Thanks.

2011-10-04  Marek Polacek  <mpolacek@redhat.com>

	* readelf.c (register_info): Assume the right size of an array.

--- elfutils/src/readelf.c.mp	2011-08-30 10:51:27.869835636 +0200
+++ elfutils/src/readelf.c	2011-08-30 10:51:42.329960296 +0200
@@ -4787,7 +4787,7 @@ register_info (Ebl *ebl, unsigned int re
 				 bits ?: &ignore, type ?: &ignore);
   if (n <= 0)
     {
-      snprintf (name, sizeof name, "reg%u", loc->regno);
+      snprintf (name, REGNAMESZ, "reg%u", loc->regno);
       if (bits != NULL)
 	*bits = loc->bits;
       if (type != NULL)

	Marek  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]