From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11827 invoked by alias); 22 Oct 2002 14:00:17 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 11806 invoked from network); 22 Oct 2002 14:00:16 -0000 Received: from unknown (HELO Cantor.suse.de) (213.95.15.193) by sources.redhat.com with SMTP; 22 Oct 2002 14:00:16 -0000 Received: from Hermes.suse.de (Charybdis.suse.de [213.95.15.201]) by Cantor.suse.de (Postfix) with ESMTP id B939016583 for ; Tue, 22 Oct 2002 16:00:15 +0200 (MEST) Resent-Message-Id: <200210221400.g9ME0EAD010346@sykes.suse.de> X-Authentication-Warning: sykes.suse.de: schwab set sender to schwab@suse.de using -f Resent-X-Yow: Yow!! It's LIBERACE and TUESDAY WELD!! High on a HILL... driving a LITTLE CAR... I wanna be in that LITTLE CAR, too!! I wanna drive off with LIBBY and TUESDAY! Resent-From: Andreas Schwab Resent-Date: Tue, 22 Oct 2002 16:00:14 +0200 X-From-Line: nobody Mon Oct 21 16:21:41 2002 To: libc-hacker@sources.redhat.com Subject: Bad alignment in locale-archive X-Yow: I feel better about world problems now! From: Andreas Schwab Date: Tue, 22 Oct 2002 07:00:00 -0000 Message-ID: User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.3.50 (ia64-suse-linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-SW-Source: 2002-10/txt/msg00080.txt.bz2 This fixes invalid alignments in the locale-archive file. Andreas. 2002-10-21 Andreas Schwab * locale/programs/locarchive.c (create_archive): Properly align offsets. (enlarge_archive): Likewise. --- locale/programs/locarchive.c.~1.16.~ 2002-10-18 11:14:16.000000000 +0200 +++ locale/programs/locarchive.c 2002-10-21 13:28:27.000000000 +0200 @@ -72,6 +72,9 @@ static const char *locnames[] = #define INITIAL_NUM_SUMS 2000 +#define ALIGN(offset, alignment) \ + (((offset) + (alignment) - 1) & -(alignment)) + static void create_archive (const char *archivefname, struct locarhandle *ah) { @@ -90,7 +93,8 @@ create_archive (const char *archivefname /* Create the initial content of the archive. */ head.magic = AR_MAGIC; - head.namehash_offset = sizeof (struct locarhead); + head.namehash_offset = ALIGN (sizeof (struct locarhead), + __alignof__ (struct namehashent)); head.namehash_used = 0; head.namehash_size = next_prime (INITIAL_NUM_NAMES); @@ -99,12 +103,15 @@ create_archive (const char *archivefname head.string_used = 0; head.string_size = INITIAL_SIZE_STRINGS; - head.locrectab_offset = head.string_offset + head.string_size; + head.locrectab_offset = ALIGN (head.string_offset + head.string_size, + __alignof__ (struct locrecent)); head.locrectab_used = 0; head.locrectab_size = INITIAL_NUM_LOCREC; - head.sumhash_offset = (head.locrectab_offset - + head.locrectab_size * sizeof (struct locrecent)); + head.sumhash_offset = ALIGN (head.locrectab_offset + + (head.locrectab_size + * sizeof (struct locrecent)), + __alignof__ (struct sumhashent)); head.sumhash_used = 0; head.sumhash_size = next_prime (INITIAL_NUM_SUMS); @@ -274,13 +281,16 @@ enlarge_archive (struct locarhandle *ah, * sizeof (struct namehashent))); newhead.string_size = MAX (2 * newhead.string_used, newhead.string_size); - newhead.locrectab_offset = newhead.string_offset + newhead.string_size; + newhead.locrectab_offset = ALIGN (newhead.string_offset + + newhead.string_size, + __alignof__ (struct locrecent)); newhead.locrectab_size = MAX (2 * newhead.locrectab_used, newhead.locrectab_size); - newhead.sumhash_offset = (newhead.locrectab_offset - + (newhead.locrectab_size - * sizeof (struct locrecent))); + newhead.sumhash_offset = ALIGN (newhead.locrectab_offset + + (newhead.locrectab_size + * sizeof (struct locrecent)), + __alignof__ (struct sumhashent)); newhead.sumhash_size = MAX (next_prime (2 * newhead.sumhash_used), newhead.sumhash_size); -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."