This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
small bugs in gettext
- To: libc-alpha at sourceware dot cygnus dot com
- Subject: small bugs in gettext
- From: Bruno Haible <haible at ilog dot fr>
- Date: Tue, 2 May 2000 15:41:40 +0200 (MET DST)
Here are three small bugs in the glibc-2000-04-28 intl library.
- The function transcmp(), used for the fast binary tree lookup, calls
strcmp (s1->msgid, s2->msgid)
twice in a row. I think one of the two comparisons ought to compare the
domain.
- In dcigettext(), strlen (msgid1) is called before msgid1 is tested
against NULL.
- The read() call in loadmsgcat.c bails out if read() is interrupted with
EINTR, and also goes into an endless loop in the very unprobable case
that the .mo file is being truncated in the exact moment that this function
attempts to read it. See gcc-2.95.2/gcc/cccp.c:safe_read() for a correct
loop.
2000-04-29 Bruno Haible <clisp.cons.org>
* intl/dcigettext.c (transcmp): Compare the domains as well.
(dcigettext): Call strlen (msgid1) after testing msgid1 against NULL,
not before.
* intl/loadmsgcat.c (_nl_load_domain): Deal with EINTR. Include
<errno.h>.
*** intl/dcigettext.c.bak Sat Apr 29 09:02:02 2000
--- intl/dcigettext.c Sun Apr 30 00:21:55 2000
***************
*** 230,236 ****
result = strcmp (s1->msgid, s2->msgid);
if (result == 0)
{
! result = strcmp (s1->msgid, s2->msgid);
if (result == 0)
{
result = s1->plindex - s2->plindex;
--- 230,236 ----
result = strcmp (s1->msgid, s2->msgid);
if (result == 0)
{
! result = strcmp (s1->domain, s2->domain);
if (result == 0)
{
result = s1->plindex - s2->plindex;
***************
*** 362,368 ****
#if defined HAVE_TSEARCH || defined _LIBC
struct known_translation_t *search;
struct known_translation_t **foundp = NULL;
! size_t msgid_len = strlen (msgid1) + 1;
#endif
size_t domainname_len;
--- 362,368 ----
#if defined HAVE_TSEARCH || defined _LIBC
struct known_translation_t *search;
struct known_translation_t **foundp = NULL;
! size_t msgid_len;
#endif
size_t domainname_len;
***************
*** 373,378 ****
__libc_rwlock_rdlock (_nl_state_lock);
#if defined HAVE_TSEARCH || defined _LIBC
if (plural == 0)
{
/* Try to find the translation among those which we found at
--- 373,380 ----
__libc_rwlock_rdlock (_nl_state_lock);
#if defined HAVE_TSEARCH || defined _LIBC
+ msgid_len = strlen (msgid1) + 1;
+
if (plural == 0)
{
/* Try to find the translation among those which we found at
*** intl/loadmsgcat.c.bak Sun Apr 23 18:39:06 2000
--- intl/loadmsgcat.c Sun Apr 30 11:35:00 2000
***************
*** 21,26 ****
--- 28,34 ----
#endif
#include <ctype.h>
+ #include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
***************
*** 177,188 ****
do
{
long int nb = (long int) read (fd, read_ptr, to_read);
! if (nb == -1)
{
close (fd);
return;
}
-
read_ptr += nb;
to_read -= nb;
}
--- 182,196 ----
do
{
long int nb = (long int) read (fd, read_ptr, to_read);
! if (nb <= 0)
{
+ #ifdef EINTR
+ if (nb == -1 && errno == EINTR)
+ continue;
+ #endif
close (fd);
return;
}
read_ptr += nb;
to_read -= nb;
}