This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Re: Bad alignment in locale-archive


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


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