+2013-05-07 Carlos O'Donell <carlos@redhat.com>
+ Jeff Law <law@redhat.com>
+
+ * 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.
+ * loadmsgcat.c (_nl_load_domain): If _nl_find_msg returns -1
+ abort loading the domain.
+
+ * dcigettext.c (_nl_find_msg): Avoid use after potential
+ free. Simplify list management for _LIBC case.
+
2013-03-07 Daiki Ueno <ueno@gnu.org>
* setlocale.c (libintl_setlocale): Signal a change of the loaded
msgid1, 1, &retlen);
#endif
+ /* Resource problems are not fatal, instead we return no
+ translation. */
+ if (__builtin_expect (retval == (char *) -1, 0))
+ goto return_untranslated;
+
if (retval != NULL)
{
domain = domain->successor[cnt];
_nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen);
# endif
+ /* Resource problems are fatal. If we continue onwards we will
+ only attempt to calloc a new conv_tab and fail later. */
+ if (__builtin_expect (nullentry == (char *) -1, 0))
+ return (char *) -1;
+
if (nullentry != NULL)
{
const char *charsetstr;
freemem_size);
# ifdef _LIBC
if (newmem != NULL)
- transmem_list = transmem_list->next;
+ transmem_list = newmem;
else
{
struct transmem_list *old = transmem_list;
malloc_count = 1;
freemem_size = INITIAL_BLOCK_SIZE;
newmem = (transmem_block_t *) malloc (freemem_size);
+# ifdef _LIBC
+ if (newmem != NULL)
+ {
+ /* Add the block to the list of blocks we have to free
+ at some point. */
+ newmem->next = transmem_list;
+ transmem_list = newmem;
+ }
+ /* Fall through and return -1. */
+# endif
}
if (__builtin_expect (newmem == NULL, 0))
{
}
# ifdef _LIBC
- /* Add the block to the list of blocks we have to free
- at some point. */
- newmem->next = transmem_list;
- transmem_list = newmem;
-
freemem = (unsigned char *) newmem->data;
freemem_size -= offsetof (struct transmem_list, data);
# else
default:
/* This is an invalid revision. */
invalid:
- /* This is an invalid .mo file. */
+ /* This is an invalid .mo file or we ran out of resources. */
free (domain->malloced);
#ifdef HAVE_MMAP
if (use_mmap)
#else
nullentry = _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen);
#endif
+ if (__builtin_expect (nullentry == (char *) -1, 0))
+ {
+#ifdef _LIBC
+ __libc_rwlock_fini (domain->conversions_lock);
+#endif
+ goto invalid;
+ }
EXTRACT_PLURAL_EXPRESSION (nullentry, &domain->plural, &domain->nplurals);
out: