public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Robustify localedef
Date: Thu, 15 Mar 2007 22:20:00 -0000	[thread overview]
Message-ID: <20070315222344.GQ1826@sunsite.mff.cuni.cz> (raw)

Hi!

cd /etc/sysconfig
localedef hu_HU.iso88592 -i hu_HU -f iso88592

segfaults after printing a bunch of various errors (errors are ok and
expected, but the segfault is not).
/etc/sysconfig is just a random directory that contains for localedef
bogus i18n source:
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"
and in addition to this user error there is also invalid charmap name.
With this, localedef calls find_translit eventhough there is
locale->categories[LC_CTYPE].ctype == NULL (locale->avail has CTYPE_LOCALE
bit set only because locfile_read ors it at the end with not_here).
When locale->categories[LC_CTYPE].ctype == NULL, we know localedef will warn
and set LC_CTYPE category to a default, which certainly has both
translit and translit_include set to NULL, so IMHO returning NULL from
find_translit in this case right away is the right thing to do.

2007-03-15  Jakub Jelinek  <jakub@redhat.com>

	* locale/programs/ld-ctype.c (find_translit): Return NULL if ctype is
	NULL.

--- libc/locale/programs/ld-ctype.c.jj	2006-11-16 17:38:02.000000000 +0100
+++ libc/locale/programs/ld-ctype.c	2007-03-15 22:46:37.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
 
@@ -1866,6 +1866,9 @@ find_translit (struct localedef_t *local
   assert (locale != NULL);
   ctype = locale->categories[LC_CTYPE].ctype;
 
+  if (ctype == NULL)
+    return NULL;
+
   if (ctype->translit != NULL)
     result = find_translit2 (ctype, charmap, wch);
 

	Jakub

                 reply	other threads:[~2007-03-15 22:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070315222344.GQ1826@sunsite.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).