This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[Bug general/23320] New: Incorrect usage of sizeof
- From: "serban at us dot ibm.com" <sourceware-bugzilla at sourceware dot org>
- To: elfutils-devel at sourceware dot org
- Date: Wed, 20 Jun 2018 17:13:07 +0000
- Subject: [Bug general/23320] New: Incorrect usage of sizeof
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=23320
Bug ID: 23320
Summary: Incorrect usage of sizeof
Product: elfutils
Version: unspecified
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: general
Assignee: unassigned at sourceware dot org
Reporter: serban at us dot ibm.com
CC: elfutils-devel at sourceware dot org
Target Milestone: ---
The following diff show the incorrect usages of the sizeof routine:
--> git diff src/ar.c src/nm.c src/readelf.c
diff --git a/src/ar.c b/src/ar.c
index bfb324c..58c8b11 100644
--- a/src/ar.c
+++ b/src/ar.c
@@ -919,7 +919,7 @@ do_oper_delete (const char *arfname, char **argv, int argc,
long int instance)
{
bool *found = alloca (sizeof (bool) * argc);
- memset (found, '\0', sizeof (found));
+ memset (found, '\0', sizeof (bool) * argc);
/* List of the files we keep. */
struct armem *to_copy = NULL;
diff --git a/src/nm.c b/src/nm.c
index f78861e..6c86298 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -752,7 +752,7 @@ show_symbols_sysv (Ebl *ebl, GElf_Word strndx, const char
*fullname,
if (unlikely (name == NULL))
{
name = alloca (sizeof "[invalid sh_name 0x12345678]");
- snprintf (name, sizeof name, "[invalid sh_name %#" PRIx32 "]",
+ snprintf (name, sizeof "[invalid sh_name 0x12345678]", "[invalid
sh_name %#" PRIx32 "]",
gelf_getshdr (scn, &shdr_mem)->sh_name);
}
scnnames[elf_ndxscn (scn)] = name;
diff --git a/src/readelf.c b/src/readelf.c
index 4032bd4..69b2abb 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -4787,7 +4787,7 @@ register_info (Ebl *ebl, unsigned int regno, const
Ebl_Register_Location *loc,
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)
--
You are receiving this mail because:
You are on the CC list for the bug.