From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13159 invoked by alias); 12 Jun 2003 17:07:34 -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 13087 invoked from network); 12 Jun 2003 17:07:33 -0000 Received: from unknown (HELO localhost.localdomain) (195.113.19.66) by sources.redhat.com with SMTP; 12 Jun 2003 17:07:33 -0000 Received: from sunsite.ms.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id h5CH7UqO010505; Thu, 12 Jun 2003 19:07:30 +0200 Received: (from jakub@localhost) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8/Submit) id h5CH7TM4010501; Thu, 12 Jun 2003 19:07:29 +0200 Date: Thu, 12 Jun 2003 17:07:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Fix localedef (era info in LC_TIME) Message-ID: <20030612170729.GA24872@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2003-06/txt/msg00021.txt.bz2 Hi! 2003-04-16 ld-time.c broke LC_TIME era data. strncpy cannot be used, since we usually need to copy 2 strings and then pad with zeros instead of one string plus zero padding. One string is there only in case of failure, where name = format = "". In this case, we copy just one string ("") and pad to 4 bytes, so that we get the needed "\0" followed by padding. 2003-06-12 Jakub Jelinek * locale/programs/ld-time.c (time_output): Don't overwrite era_format with zeros. --- libc/locale/programs/ld-time.c.jj 2003-04-23 14:11:51.000000000 -0400 +++ libc/locale/programs/ld-time.c 2003-06-12 12:41:51.000000000 -0400 @@ -670,7 +670,7 @@ time_output (struct localedef_t *locale, idx[1 + last_idx] = idx[last_idx]; for (num = 0; num < time->num_era; ++num) { - size_t l; + size_t l, l2; iov[2 + cnt].iov_base = (void *) &time->era_entries[num].direction; iov[2 + cnt].iov_len = sizeof (int32_t); @@ -699,15 +699,14 @@ time_output (struct localedef_t *locale, l = ((char *) rawmemchr (time->era_entries[num].format, '\0') - time->era_entries[num].name) + 1; - l = (l + 3) & ~3; - iov[2 + cnt].iov_base = alloca (l); - /* This time we *really* want to use the properties of strncpy. */ - strncpy (iov[2 + cnt].iov_base, time->era_entries[num].name, - l); - iov[2 + cnt].iov_len = l; + l2 = (l + 3) & ~3; + iov[2 + cnt].iov_base = alloca (l2); + memset (mempcpy (iov[2 + cnt].iov_base, time->era_entries[num].name, l), + '\0', l2 - l); + iov[2 + cnt].iov_len = l2; ++cnt; - idx[1 + last_idx] += 8 * sizeof (int32_t) + l; + idx[1 + last_idx] += 8 * sizeof (int32_t) + l2; assert (idx[1 + last_idx] % 4 == 0); Jakub