This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug locale/22338] New: locale: Use the right type for allocation sizes (non-portable assumptions).
- From: "carlos at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Mon, 23 Oct 2017 15:51:00 +0000
- Subject: [Bug locale/22338] New: locale: Use the right type for allocation sizes (non-portable assumptions).
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=22338
Bug ID: 22338
Summary: locale: Use the right type for allocation sizes
(non-portable assumptions).
Product: glibc
Version: 2.27
Status: NEW
Severity: minor
Priority: P2
Component: locale
Assignee: unassigned at sourceware dot org
Reporter: carlos at redhat dot com
Target Milestone: ---
In ld-ctype.c and locfile.c we use the wrong type for sizing the allocation, we
use the sizeof the original type, but that's not correct, it should be the size
of the element size. In both cases we can use the sizeof the dereferenced name
to get the right value.
The oringal code is fine, but it's a non-portable assumption to say that sizeof
(foo **) == sizeof (foo *), it could in theory be different.
We should just fix this.
diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c
index afb431b..b92f857 100644
--- a/locale/programs/ld-ctype.c
+++ b/locale/programs/ld-ctype.c
@@ -3889,7 +3889,7 @@ allocate_arrays (struct locale_ctype_t *ctype, const
struct charmap_t *charmap,
/* Next we allocate an array large enough and fill in the values. */
sorted = (struct translit_t **) alloca (number
- * sizeof (struct translit_t **));
+ * sizeof (*sorted));
runp = ctype->translit;
number = 0;
do
diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c
index b52efcf..10e6092 100644
--- a/locale/programs/locfile.c
+++ b/locale/programs/locfile.c
@@ -426,7 +426,7 @@ siblings_uncached (const char *output_path)
*p++ = '/';
*p = '\0';
elems = (const char **) xrealloc ((char *) elems,
- (nelems + 2) * sizeof (char **));
+ (nelems + 2) * sizeof (*elems));
elems[nelems++] = other_path;
}
else
--
You are receiving this mail because:
You are on the CC list for the bug.