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] | |
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 <jakub@redhat.com>
* 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
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |