Modify

Opened 10 years ago

Closed 10 years ago

#2941 closed defect (fixed)

uClibc 0.9.29: __progname and openssh segfaults

Reported by: Davide Guerri <d.guerri@…> Owned by: developers
Priority: normal Milestone:
Component: toolchain Version:
Keywords: Cc:

Description

Some programs, most notably openssh suite, define the __progname variable as an alias for argv[0].
For instance, openssh-4.7p1 includes the following code:

from build_dir/i386/openssh-4.7p1/openbsd-compat/bsd-misc.c

#ifndef HAVE___PROGNAME
char *__progname;
#endif

/*
 * NB. duplicate __progname in case it is an alias for argv[0]
 * Otherwise it may get clobbered by setproctitle()
 */
char *ssh_get_progname(char *argv0)
{
#ifdef HAVE___PROGNAME
        extern char *__progname;

        return xstrdup(__progname);
#else
        char *p;

        if (argv0 == NULL)
                return ("unknown");     /* XXX */
        p = strrchr(argv0, '/');
        if (p == NULL)
                p = argv0;
        else
                p++;

        return (xstrdup(p));
#endif
}

Openwrt kamikaze trunk (r10072) compiles uclibc with __UCLIBC_HAS___PROGNAME__ and without __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__.
As a consequence, __uClibc_main() doesn't set __progname although it defines this variable.
(btw, __progname is more "pertinent" in BSD...).

from build_dir/toolchain-i386_gcc4.1.2/uClibc-0.9.29/libc/misc/internals/__uClibc_main.c

[...]
#ifdef __UCLIBC_HAS___PROGNAME__
strong_alias (__uclibc_progname, __progname)
#endif
#ifdef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
attribute_hidden const char *__progname_full = NULL;
strong_alias (__uclibc_progname, program_invocation_short_name)
strong_alias (__progname_full, program_invocation_name)
#endif
[...]

from build_dir/toolchain-i386_gcc4.1.2/uClibc-0.9.29/libc/misc/internals/__uClibc_main.c::__uClibc_main()

[...]
#ifdef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
    __progname_full = *argv;
    __progname = strrchr(*argv, '/');
    if (__progname != NULL)
        ++__progname;
    else
        __progname = __progname_full;
#else
    __uclibc_progname = *argv;
#endif
[...]

The following patch resolves the issue. The issue could be resolved also by unsetting UCLIBC_HAS___PROGNAME,
but i haven't tryied it (i have no idea if there can be side effects for this).
N.B.: i think it could be usefull to define UCLIBC_HAS_PROGRAM_INVOCATION_NAME for all the architectures
in toolchain/uClibc/config/.

Index: toolchain/uClibc/config/i386
===================================================================
--- toolchain/uClibc/config/i386        (revision 10072)
+++ toolchain/uClibc/config/i386        (working copy)
@@ -97,7 +97,7 @@
 # UCLIBC_SUSV3_LEGACY is not set
 UCLIBC_SUSV3_LEGACY_MACROS=y
 # UCLIBC_HAS_SHADOW is not set
-# UCLIBC_HAS_PROGRAM_INVOCATION_NAME is not set
+UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y
 UCLIBC_HAS___PROGNAME=y
 # UNIX98PTY_ONLY is not set
 ASSUME_DEVPTS=y

Attachments (0)

Change History (1)

comment:1 Changed 10 years ago by nbd

  • Resolution set to fixed
  • Status changed from new to closed

config changed in r10358

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.