From: Guillem Jover Date: Sat, 30 Jan 2010 21:00:18 +0000 (+0100) Subject: Fix setprogname to strip leading paths from progname X-Git-Tag: 0.3.0~42 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=11f2c32df2722a758f150fb3242d208904ffdacb;p=thirdparty%2Flibbsd.git Fix setprogname to strip leading paths from progname --- diff --git a/src/progname.c b/src/progname.c index a5675c0..ef56144 100644 --- a/src/progname.c +++ b/src/progname.c @@ -29,6 +29,8 @@ Rejected in glibc (http://sourceware.org/ml/libc-alpha/2006-03/msg00125.html) */ +#include + #include static const char *__progname = NULL; @@ -40,7 +42,13 @@ getprogname(void) } void -setprogname(const char *new) +setprogname(const char *progname) { - __progname = new; + const char *last_slash; + + last_slash = strrchr(progname, '/'); + if (last_slash == NULL) + __progname = progname; + else + __progname = last_slash + 1; }