Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When odhcpd receives a DHCPv6 client request it calls external /usr/bin/basename binary #214

Open
Konstantin-Glukhov opened this issue Feb 14, 2024 · 0 comments

Comments

@Konstantin-Glukhov
Copy link

Konstantin-Glukhov commented Feb 14, 2024

When odhcpd receives a DHCPv6 client request it calls basename() function. Somehow it invokes the external /usr/bin/basename with incorrect arguments. Is it a linkage problem with libc.so on arm hardware?

# odhcpd
odhcpd[536]: Sending RS to wan6
odhcpd[536]: Got a RA on wan6
odhcpd[536]: Forward a RA on lan
odhcpd[536]: DHCPV6 SOLICIT IA_NA from XXX on lan: no addresses available
basename: missing operand
Try 'basename --help' for more information.
odhcpd[536]: DHCPV6 SOLICIT IA_NA from XXX on lan: no addresses available
odhcpd[536]: Sending RS to wan6
odhcpd[536]: Got a RA on wan6
odhcpd[536]: Forward a RA on lan
^C
# which basename
/usr/bin/basename
# ls -l /usr/bin/basename
lrwxrwxrwx    1 root     root          31 Feb 14 06:23 /usr/bin/basename -> /usr/libexec/basename-coreutils*

I wrote a simple test function and it works as expected:

cat t.c
#include <stdio.h>
#include <libgen.h>

int main() {
    const char *path = "/path/to/some/file.txt";

    char *base = basename((char *)path);

    printf("Base name: %s\n", base);

    return 0;
}
arm-openwrt-linux-gcc t.c -o t
file t
t: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-armhf.so.1, with debug_info, not stripped
scp t router:/tmp

Run on router:

/tmp/t
Base name: file.txt

I also checked all of the dynamic libraries loaded by odhcpd, and the only one that has basename() in it is libc.so:

ldd /usr/sbin/odhcpd
        /lib/ld-musl-armhf.so.1 (0xb6f56000)
        libubox.so.20230523 => /lib/libubox.so.20230523 (0xb6f37000)
        libuci.so => /lib/libuci.so (0xb6f2d000)
        libnl-tiny.so.1 => /usr/lib/libnl-tiny.so.1 (0xb6f25000)
        libubus.so.20230605 => /lib/libubus.so.20230605 (0xb6f1f000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb6f12000)
        libc.so => /lib/ld-musl-armhf.so.1 (0xb6f56000)

What causes odhcpd to invoke the external program?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant