1 2013-05-03 Carlos O'Donell <carlos at redhat.com>
3 * intl/dcigettext.c (DCIGETTEXT): Skip translating if _nl_find_msg returns -1.
4 (_nl_find_msg): Return -1 if recursive call returned -1. If newmem is null
6 * intl/loadmsgcat.c (_nl_load_domain): If _nl_find_msg returns -1 abort
9 diff -Nrup a/intl/dcigettext.c b/intl/dcigettext.c
10 --- a/intl/dcigettext.c 2010-05-04 07:27:23.000000000 -0400
11 +++ b/intl/dcigettext.c 2013-08-01 00:11:54.616363264 -0400
12 @@ -640,6 +640,11 @@ DCIGETTEXT (domainname, msgid1, msgid2,
13 retval = _nl_find_msg (domain->successor[cnt], binding,
16 + /* Resource problems are not fatal, instead we return no
18 + if (__builtin_expect (retval == (char *) -1, 0))
19 + goto no_translation;
23 domain = domain->successor[cnt];
24 @@ -943,6 +948,11 @@ _nl_find_msg (domain_file, domainbinding
26 _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen);
28 + /* Resource problems are fatal. If we continue onwards we will
29 + only attempt to calloc a new conv_tab and fail later. */
30 + if (__builtin_expect (nullentry == (char *) -1, 0))
33 if (nullentry != NULL)
35 const char *charsetstr;
36 @@ -1156,7 +1166,7 @@ _nl_find_msg (domain_file, domainbinding
40 - transmem_list = transmem_list->next;
41 + transmem_list = newmem;
44 struct transmem_list *old = transmem_list;
45 @@ -1171,6 +1181,16 @@ _nl_find_msg (domain_file, domainbinding
47 freemem_size = INITIAL_BLOCK_SIZE;
48 newmem = (transmem_block_t *) malloc (freemem_size);
52 + /* Add the block to the list of blocks we have to free
54 + newmem->next = transmem_list;
55 + transmem_list = newmem;
57 + /* Fall through and return -1. */
60 if (__builtin_expect (newmem == NULL, 0))
62 @@ -1181,11 +1201,6 @@ _nl_find_msg (domain_file, domainbinding
66 - /* Add the block to the list of blocks we have to free
68 - newmem->next = transmem_list;
69 - transmem_list = newmem;
71 freemem = (unsigned char *) newmem->data;
72 freemem_size -= offsetof (struct transmem_list, data);
74 @@ -1402,7 +1417,7 @@ get_output_charset (domainbinding)
75 return _NL_CURRENT (LC_CTYPE, CODESET);
78 - extern const char *locale_charset PARAMS ((void);
79 + extern const char *locale_charset PARAMS ((void));
80 return locale_charset ();
83 diff -Nrup a/intl/loadmsgcat.c b/intl/loadmsgcat.c
84 --- a/intl/loadmsgcat.c 2010-05-04 07:27:23.000000000 -0400
85 +++ b/intl/loadmsgcat.c 2013-08-01 00:12:48.448237849 -0400
86 @@ -1235,7 +1235,7 @@ _nl_load_domain (domain_file, domainbind
88 /* This is an invalid revision. */
90 - /* This is an invalid .mo file. */
91 + /* This is an invalid .mo file or we ran out of resources. */
92 free (domain->malloced);
95 @@ -1255,6 +1255,12 @@ _nl_load_domain (domain_file, domainbind
97 /* Get the header entry and look for a plural specification. */
98 nullentry = _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen);
99 + if (__builtin_expect (nullentry == (char *) -1, 0))
101 + __libc_rwlock_fini (domain->conversions_lock);
105 EXTRACT_PLURAL_EXPRESSION (nullentry, &domain->plural, &domain->nplurals);