glibc/intl
Carlos O'Donell 7a44c18fb4 Fix _nl_find_msg malloc failure case, and callers.
This patch fixes two issues, and perhaps should be two distinct commits,
but I present it here as one for the sake of completeness.

Commit 006dd86111 fails to check malloc's
return in intl/dcigettext.c (_nl_find_msg):
~~~
      freemem_size = INITIAL_BLOCK_SIZE;
      newmem = (transmem_block_t *) malloc (freemem_size);
...
      newmem->next = transmem_list;
      transmem_list = newmem;
~~~
If malloc fails then newmem is NULL then newmem->next results in a
fault.

The fix is easy enough, check for newmem != NULL, and fall through to
the error condition below which returns (char *) -1 e.g. resource error.

The problem is that returning (char *) -1  will break all sorts of other
code, so while what we did is correct, the real failure case fix is
slightly broader.

There are 4 other places where _nl_find_msg is called, one is OK, the
other three are fixed to handle -1 error return value.

No regressions on x86-64 or x86.

However, no regressions isn't really a useful metric for this code.

The change was tested as documented here:
http://sourceware.org/glibc/wiki/Testing/WhiteBox
using SystemTap for fault injection to simulate malloc failure.

---

2013-05-03  Carlos O'Donell  <carlos at redhat.com>

	[BZ #15441]
	* intl/dcigettext.c (DCIGETTEXT): Skip translating if _nl_find_msg
	returns -1.
	(_nl_find_msg): Return -1 if recursive call returned -1. If newmem is
	null return -1.
	* intl/loadmsgcat.c (_nl_load_domain): If _nl_find_msg returns -1 abort
	loading the domain.
2013-05-22 14:50:26 -04:00
..
bindtextdom.c
dcgettext.c
dcigettext.c Fix _nl_find_msg malloc failure case, and callers. 2013-05-22 14:50:26 -04:00
dcngettext.c
Depend
dgettext.c
dngettext.c
explodename.c
finddomain.c
gettext.c
gettextP.h
gmo.h
hash-string.c
hash-string.h
l10nflist.c
libintl.h
loadinfo.h
loadmsgcat.c Fix _nl_find_msg malloc failure case, and callers. 2013-05-22 14:50:26 -04:00
locale.alias
localealias.c
Makefile Remove bounded-pointers build system support. 2013-02-15 15:07:54 +00:00
ngettext.c
plural-eval.c
plural-exp.c
plural-exp.h
plural.c
plural.y
po2test.awk
textdomain.c
translit.po
tst-codeset.c
tst-gettext2.c
tst-gettext2.sh
tst-gettext3.c
tst-gettext4-de.po
tst-gettext4-fr.po
tst-gettext4.c
tst-gettext4.sh
tst-gettext5.c
tst-gettext6.c
tst-gettext6.sh
tst-gettext.c
tst-gettext.sh
tst-ngettext.c
tst-translit.c
tst-translit.sh
tstcodeset.po
tstlang1.po
tstlang2.po
Versions