diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-06-30 05:57:47 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-06-30 05:57:47 +0000 |
commit | e43e0dd6b3ecdbf8980d0bfd47cea208ee8e9062 (patch) | |
tree | e7c5ff600da4e2968ba69861ddbf528af88d0c35 | |
parent | 040cf4baf7c85c2c357e63f70935f86a90ab512d (diff) | |
download | glibc-e43e0dd6b3ecdbf8980d0bfd47cea208ee8e9062.tar.gz glibc-e43e0dd6b3ecdbf8980d0bfd47cea208ee8e9062.tar.xz glibc-e43e0dd6b3ecdbf8980d0bfd47cea208ee8e9062.zip |
Update.
* locale/loadlocale.c (_nl_load_locale): Make sure all locale data used as words is properly aligned.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | locale/loadlocale.c | 7 | ||||
-rw-r--r-- | locale/programs/ld-ctype.c | 42 |
3 files changed, 29 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog index ddaf019d7c..ff384ef0fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2000-06-29 Ulrich Drepper <drepper@redhat.com> + * locale/loadlocale.c (_nl_load_locale): Make sure all locale data + used as words is properly aligned. + * locale/programs/ld-ctype.c (ctype_output): Don't generate unaligned data files. diff --git a/locale/loadlocale.c b/locale/loadlocale.c index 54336c4c49..1478579c55 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -18,6 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include <assert.h> #include <errno.h> #include <fcntl.h> #include <stdlib.h> @@ -215,7 +216,11 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) goto puntmap; } if (__builtin_expect (_nl_value_types[category][cnt] == word, 0)) - newdata->values[cnt].word = *((u_int32_t *) (newdata->filedata + idx)); + { + assert (idx % 4 == 0); + newdata->values[cnt].word = + *((u_int32_t *) (newdata->filedata + idx)); + } else newdata->values[cnt].string = newdata->filedata + idx; } diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c index c00d2cb2cc..d3e3d7c30a 100644 --- a/locale/programs/ld-ctype.c +++ b/locale/programs/ld-ctype.c @@ -833,7 +833,7 @@ void ctype_output (struct localedef_t *locale, struct charmap_t *charmap, const char *output_path) { - static const char nulbytes[3] = { 0, 0, 0 }; + static const char nulbytes[4] = { 0, 0, 0, 0 }; struct locale_ctype_t *ctype = locale->categories[LC_CTYPE].ctype; const size_t nelems = (_NL_ITEM_INDEX (_NL_NUM_LC_CTYPE) + (ctype->map_collection_nr - 2)); @@ -936,7 +936,7 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap, = strlen (ctype->classnames[cnt]) + 1; total += iov[2 + elem + offset].iov_len; } - iov[2 + elem + offset].iov_base = (void *) "\0\0\0"; + iov[2 + elem + offset].iov_base = (void *) nulbytes; iov[2 + elem + offset].iov_len = 1 + (4 - ((total + 1) % 4)); total += 1 + (4 - ((total + 1) % 4)); @@ -954,7 +954,7 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap, = strlen (ctype->mapnames[cnt]) + 1; total += iov[2 + elem + offset].iov_len; } - iov[2 + elem + offset].iov_base = (void *) "\0\0\0"; + iov[2 + elem + offset].iov_base = (void *) nulbytes; iov[2 + elem + offset].iov_len = 1 + (4 - ((total + 1) % 4)); total += 1 + (4 - ((total + 1) % 4)); @@ -993,6 +993,12 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap, break; case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS_WC_LEN): + /* Align entries. */ + iov[2 + elem + offset].iov_base = (void *) nulbytes; + iov[2 + elem + offset].iov_len = (4 - idx[elem] % 4) % 4; + idx[elem] += iov[2 + elem + offset].iov_len; + ++offset; + iov[2 + elem + offset].iov_base = alloca (sizeof (uint32_t)); iov[2 + elem + offset].iov_len = sizeof (uint32_t); *(uint32_t *) iov[2 + elem + offset].iov_base = @@ -1000,15 +1006,7 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap, idx[elem + 1] = idx[elem] + sizeof (uint32_t); break; - case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_MB): - /* Align entries. */ - iov[2 + elem + offset].iov_base = (void *) nulbytes; - iov[2 + elem + offset].iov_len = (4 - idx[elem] % 4) % 4; - idx[elem] += iov[2 + elem + offset].iov_len; - ++offset; - /* FALLTRHOUGH */ - - case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS1_MB) ... _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS9_MB): + case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_MB) ... _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS9_MB): /* Compute the length of all possible characters. For INDIGITS there might be more than one. We simply concatenate all of them with a NUL byte following. The NUL byte wouldn't be @@ -1048,15 +1046,7 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap, idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len; break; - case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_WC): - /* Align entries. */ - iov[2 + elem + offset].iov_base = (void *) nulbytes; - iov[2 + elem + offset].iov_len = (4 - idx[elem] % 4) % 4; - idx[elem] += iov[2 + elem + offset].iov_len; - ++offset; - /* FALLTHROUGH */ - - case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS1_WC) ... _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS9_WC): + case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_WC) ... _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS9_WC): total = ctype->wcdigits_act / 10; iov[2 + elem + offset].iov_base = @@ -1070,7 +1060,15 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap, idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len; break; - case _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT0_WC) ... _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT9_WC): + case _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT0_WC): + /* Align entries. */ + iov[2 + elem + offset].iov_base = (void *) nulbytes; + iov[2 + elem + offset].iov_len = (4 - idx[elem] % 4) % 4; + idx[elem] += iov[2 + elem + offset].iov_len; + ++offset; + /* FALLTRHOUGH */ + + case _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT1_WC) ... _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT9_WC): cnt = elem - _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT0_WC); iov[2 + elem + offset].iov_base = &ctype->wcoutdigits[cnt]; iov[2 + elem + offset].iov_len = sizeof (uint32_t); |