bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gettext clobbers errno (was: Re: Fwd: Re: error.c: "Unknown system error


From: Bruno Haible
Subject: gettext clobbers errno (was: Re: Fwd: Re: error.c: "Unknown system error" should report errno value)
Date: Sun, 14 Oct 2007 18:06:38 +0200
User-agent: KMail/1.5.4

Martin Koeppe wrote:
> I just found the bug in gettext causing this trouble. Unfortunately I 
> didn't find a gettext mailing list.

For most GNU programs, you find the bug reporting address at the end of
the "<program> --help" output. "gettext --help" is in this category.

> Gettext is 0.16.1, file dcigettext.c, function libintl_dcigettext()
> 
> (gdb) display errno
> 1: {<data variable, no debug info>} 4321340 = 13
> (gdb) s
> 582       gl_rwlock_rdlock (tree_lock);
> 1: {<data variable, no debug info>} 4321340 = 13
> (gdb) s
> 584       foundp = (struct known_translation_t **) tfind (search, 
> &root, transcmp);
> 1: {<data variable, no debug info>} 4321340 = 13
> (gdb) frame
> #0  libintl_dcigettext (domainname=0x894d28 "coreutils", 
> msgid1=0x41b78a "`",
>      msgid2=0x0, plural=0, n=0, category=6) at ./dcigettext.c:584
> 584       foundp = (struct known_translation_t **) tfind (search, 
> &root, transcmp);
> (gdb) print errno
> $1 = 13
> (gdb) s
> 586       gl_rwlock_unlock (tree_lock);
> 1: {<data variable, no debug info>} 4321340 = 2
> (gdb) print errno
> $1 = 2
> (gdb) q
> 
> Apparently, on interix tfind() on line 584 changes errno, before it 
> is saved in line 587. So the patch below should be applied.

Thank you for this analysis! I'm applying this patch.


2007-10-14  Bruno Haible  <address@hidden>

        * dcigettext.c (DCIGETTEXT): Save errno also around the tfind() call.
        Needed because Interix 3.5 tfind() clobbers errno.
        Reported by Martin Koeppe <address@hidden>.

*** dcigettext.c        14 Oct 2007 15:58:47 -0000      1.35
--- dcigettext.c        14 Oct 2007 16:02:09 -0000
***************
*** 522,527 ****
--- 522,530 ----
            : n == 1 ? (char *) msgid1 : (char *) msgid2);
  #endif
  
+   /* Preserve the `errno' value.  */
+   saved_errno = errno;
+ 
    gl_rwlock_rdlock (_nl_state_lock);
  
    /* If DOMAINNAME is NULL, we are interested in the default domain.  If
***************
*** 592,604 ****
        retval = (char *) (*foundp)->translation;
  
        gl_rwlock_unlock (_nl_state_lock);
        return retval;
      }
  #endif
  
-   /* Preserve the `errno' value.  */
-   saved_errno = errno;
- 
    /* See whether this is a SUID binary or not.  */
    DETERMINE_SECURE;
  
--- 595,605 ----
        retval = (char *) (*foundp)->translation;
  
        gl_rwlock_unlock (_nl_state_lock);
+       errno = saved_errno;
        return retval;
      }
  #endif
  
    /* See whether this is a SUID binary or not.  */
    DETERMINE_SECURE;
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]