ce426f
2013-05-03  Carlos O'Donell  <carlos at redhat.com>
ce426f
ce426f
	* intl/dcigettext.c (DCIGETTEXT): Skip translating if _nl_find_msg returns -1.
ce426f
	(_nl_find_msg): Return -1 if recursive call returned -1. If newmem is null
ce426f
	return -1.
ce426f
	* intl/loadmsgcat.c (_nl_load_domain): If _nl_find_msg returns -1 abort
ce426f
	loading the domain.
ce426f
ce426f
diff --git glibc-2.17-c758a686/intl/dcigettext.c glibc-2.17-c758a686/intl/dcigettext.c
ce426f
index 110307b..f4aa215 100644
ce426f
--- glibc-2.17-c758a686/intl/dcigettext.c
ce426f
+++ glibc-2.17-c758a686/intl/dcigettext.c
ce426f
@@ -638,6 +638,11 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
ce426f
 		  retval = _nl_find_msg (domain->successor[cnt], binding,
ce426f
 					 msgid1, 1, &retlen);
ce426f
 
ce426f
+		  /* Resource problems are not fatal, instead we return no
ce426f
+		     translation.  */
ce426f
+		  if (__builtin_expect (retval == (char *) -1, 0))
ce426f
+		    goto no_translation;
ce426f
+
ce426f
 		  if (retval != NULL)
ce426f
 		    {
ce426f
 		      domain = domain->successor[cnt];
ce426f
@@ -941,6 +946,11 @@ _nl_find_msg (domain_file, domainbinding, msgid, convert, lengthp)
ce426f
 	    nullentry =
ce426f
 	      _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen);
ce426f
 
ce426f
+	    /* Resource problems are fatal.  If we continue onwards we will
ce426f
+	       only attempt to calloc a new conv_tab and fail later.  */
ce426f
+	    if (__builtin_expect (nullentry == (char *) -1, 0))
ce426f
+	      return (char *) -1;
ce426f
+
ce426f
 	    if (nullentry != NULL)
ce426f
 	      {
ce426f
 		const char *charsetstr;
ce426f
@@ -1170,10 +1180,14 @@ _nl_find_msg (domain_file, domainbinding, msgid, convert, lengthp)
ce426f
 		      freemem_size = INITIAL_BLOCK_SIZE;
ce426f
 		      newmem = (transmem_block_t *) malloc (freemem_size);
ce426f
 # ifdef _LIBC
ce426f
-		      /* Add the block to the list of blocks we have to free
ce426f
-			 at some point.  */
ce426f
-		      newmem->next = transmem_list;
ce426f
-		      transmem_list = newmem;
ce426f
+		      if (newmem != NULL)
ce426f
+			{
ce426f
+			  /* Add the block to the list of blocks we have to free
ce426f
+			     at some point.  */
ce426f
+			  newmem->next = transmem_list;
ce426f
+			  transmem_list = newmem;
ce426f
+			}
ce426f
+		      /* Fall through and return -1.  */
ce426f
 # endif
ce426f
 		    }
ce426f
 		  if (__builtin_expect (newmem == NULL, 0))
ce426f
diff --git glibc-2.17-c758a686/intl/loadmsgcat.c glibc-2.17-c758a686/intl/loadmsgcat.c
ce426f
index e4b7b38..ac90ed1 100644
ce426f
--- glibc-2.17-c758a686/intl/loadmsgcat.c
ce426f
+++ glibc-2.17-c758a686/intl/loadmsgcat.c
ce426f
@@ -1237,7 +1237,7 @@ _nl_load_domain (domain_file, domainbinding)
ce426f
     default:
ce426f
       /* This is an invalid revision.  */
ce426f
     invalid:
ce426f
-      /* This is an invalid .mo file.  */
ce426f
+      /* This is an invalid .mo file or we ran out of resources.  */
ce426f
       free (domain->malloced);
ce426f
 #ifdef HAVE_MMAP
ce426f
       if (use_mmap)
ce426f
@@ -1257,6 +1257,11 @@ _nl_load_domain (domain_file, domainbinding)
ce426f
 
ce426f
   /* Get the header entry and look for a plural specification.  */
ce426f
   nullentry = _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen);
ce426f
+  if (__builtin_expect (nullentry == (char *) -1, 0))
ce426f
+    {
ce426f
+      __libc_rwlock_fini (domain->conversions_lock);
ce426f
+      goto invalid;
ce426f
+    }
ce426f
   EXTRACT_PLURAL_EXPRESSION (nullentry, &domain->plural, &domain->nplurals);
ce426f
 
ce426f
  out: