Bad alignment in locale-archive
Jakub Jelinek
jakub@redhat.com
Tue Oct 22 07:29:00 GMT 2002
On Mon, Oct 21, 2002 at 04:21:39PM +0200, Andreas Schwab wrote:
> This fixes invalid alignments in the locale-archive file.
I don't think we should use __alignof__, what if it is different among
arches with the same endianity. locale-archive format should be only
endianess dependent, not anything else.
Furthermore, all but one alignment is unnecessary, and in that one case
(enlarge_archive's
newhead.locrectab_offset = newhead.string_offset + newhead.string_size;
) it is IMHO better to make sure string_size is always multiple of 4, like:
2002-10-22 Jakub Jelinek <jakub@redhat.com>
* locale/programs/locarchive.c (enlarge_archive): Make sure
string_size is always multiple of 4.
Reported by Andreas Schwab <schwab@suse.de>.
--- libc/locale/programs/locarchive.c.jj 2002-10-22 15:34:37.000000000 +0200
+++ libc/locale/programs/locarchive.c 2002-10-22 16:32:38.000000000 +0200
@@ -272,7 +272,8 @@ enlarge_archive (struct locarhandle *ah,
newhead.string_offset = (newhead.namehash_offset
+ (newhead.namehash_size
* sizeof (struct namehashent)));
- newhead.string_size = MAX (2 * newhead.string_used, newhead.string_size);
+ newhead.string_size = MAX ((2 * newhead.string_used + 3) & -4,
+ newhead.string_size);
newhead.locrectab_offset = newhead.string_offset + newhead.string_size;
newhead.locrectab_size = MAX (2 * newhead.locrectab_used,
Jakub
More information about the Libc-hacker
mailing list