bug-fileutils
[Top][All Lists]
Advanced

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

Usage of gettext() in chown


From: Tetsuya Furukawa
Subject: Usage of gettext() in chown
Date: Fri, 9 May 2003 19:03:30 +0900
User-agent: Mutt/1.4i-ja.1

Hello,

On Solaris 7/8 SPARC edition with japanese environment, the following
command line dumped core:

    # LANG=ja /usr/local/bin/chown myname file
    Segmentation fault (core dumped)

In the same condition, the following was normally done:

    # LANG=C /usr/local/bin/chown myname file


I checked the core file:

(gdb) bt
#0  0xff1b67fc in strcmp () from /usr/lib/libc.so.1
#1  0xff1f8880 in key_2_text () from /usr/lib/libc.so.1
#2  0xff1f8734 in dcgettext_u () from /usr/lib/libc.so.1
#3  0xff1f7ef0 in gettext () from /usr/lib/libc.so.1
#4  0x171d8 in parse_user_spec (spec_arg=0xffbef799 "myname", uid=0xffbef5b4, 
    gid=0xffbef5b0, username_arg=0xffbef5a0, groupname_arg=0xffbef5a4)
    at userspec.c:353
#5  0x12028 in main (argc=3, argv=0xffbef62c) at chown.c:225
(gdb) up 4
#4  0x171d8 in parse_user_spec (spec_arg=0xffbef799 "myname", uid=0xffbef5b4, 
    gid=0xffbef5b0, username_arg=0xffbef5a0, groupname_arg=0xffbef5a4)
    at userspec.c:353
353       return _(error_msg);
(gdb) print error_msg
$1 = 0x0

parse_user_spec() gives a null pointer to gettext(), and expects
that it returns a null pointer.
However, Solaris's manpage
<http://docs.sun.com/db/doc/806-0627/6j9vhfmu1?a=view> says:

    char *gettext(const char *msgid);
    If msgid is a null pointer, the return value is undefined.

So the usage of gettext() is wrong. (Though the segmentation fault
is a Solaris's bug)
I don't know the specifications of gettext() on other platforms.

The following patch will fix the problem.

==============BEGIN==============
--- lib/userspec.c.orig Sat Dec 16 22:23:49 2000
+++ lib/userspec.c      Thu May  8 19:30:39 2003
@@ -350,7 +350,7 @@
       goto retry;
     }
 
-  return _(error_msg);
+  return error_msg ? _(error_msg) : NULL;
 }
 
 #ifdef TEST
==============END==============

Thank you.
-- 
Tetsuya FURUKAWA




reply via email to

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