[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patches] [PATCH] localedef cross endianess problem



Hello,

we're using the stand alone locale def program quite happily, but we
noticed a segfault when trying to generate a locale archive for a
different endianess (i.e. x64 -> ppc).

please keep me on CC, I'm not subscribed.

cheers, Marc

---

From: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
Subject: fix cross endianess segfault

This patch fixes a segfault that occurs if the generated locale
archive endianess does not equal the hosts endianess.

Without this patch the offset in filedata->strindex is in the
wrong endianess which means a quite big offset pointing beyond
the allocated data, which causes the later strlen to segfault.
This patch swaps the offset to the correct endianess. 

Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>

---
 locale/programs/locarchive.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: libc/locale/programs/locarchive.c
===================================================================
--- libc.orig/locale/programs/locarchive.c
+++ libc/locale/programs/locarchive.c
@@ -43,6 +43,7 @@
 #include "../localeinfo.h"
 #include "../locarchive.h"
 #include "localedef.h"
+#include "locfile.h"
 
 /* Define the hash function.  We define the function as static inline.
    We must change the name so as not to conflict with simple-hash.h.  */
@@ -974,7 +975,7 @@ add_locale_to_archive (ah, name, data, r
       } *filedata = data[LC_CTYPE].addr;
       char *normalized_codeset_name = NULL;
       codeset = (char *) filedata
-	+ filedata->strindex[_NL_ITEM_INDEX (_NL_CTYPE_CODESET_NAME)];
+	+ maybe_swap_uint32(filedata->strindex[_NL_ITEM_INDEX (_NL_CTYPE_CODESET_NAME)]);
 
       normalized_codeset = _nl_normalize_codeset (codeset, strlen (codeset));
       mask |= XPG_NORM_CODESET;

-- 
Pengutronix e.K.                         | Marc Kleine-Budde           |
Linux Solutions for Science and Industry | Phone: +49-231-2826-924     |
Vertretung West/Dortmund                 | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686         | http://www.pengutronix.de   |

Attachment: signature.asc
Description: OpenPGP digital signature