From a8f934ffada25bcacbf4b234a0c80b4420908bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Sun, 18 Feb 2024 21:31:00 +0700 Subject: [PATCH] util-linux: su: fix basename ptr truncate to int Fix: #48758 --- .../patches/su-common-fix-ptr-truncate.patch | 58 +++++++++++++++++++ srcpkgs/util-linux/template | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/util-linux/patches/su-common-fix-ptr-truncate.patch diff --git a/srcpkgs/util-linux/patches/su-common-fix-ptr-truncate.patch b/srcpkgs/util-linux/patches/su-common-fix-ptr-truncate.patch new file mode 100644 index 00000000000..24cdb7de3e5 --- /dev/null +++ b/srcpkgs/util-linux/patches/su-common-fix-ptr-truncate.patch @@ -0,0 +1,58 @@ +From 77454e58d58f904cfdc02d3ca5bb65f1bd8739fc Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sun, 3 Dec 2023 19:59:46 -0800 +Subject: [PATCH] login-utils: include libgen.h for basename API + +musl has removed the non-prototype declaration of basename from string.h [1] which now results in build errors with clang-17+ compiler + +include libgen.h for using the posix declaration of the funciton. + +Fixes + +../util-linux-2.39.2/login-utils/su-common.c:847:20: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] + 847 | shell_basename = basename(shell); + | ^ + +[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7 + +Signed-off-by: Khem Raj +--- + login-utils/su-common.c | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/login-utils/su-common.c b/login-utils/su-common.c +index c5c0102e5..06ce5dba2 100644 +--- a/login-utils/su-common.c ++++ b/login-utils/su-common.c +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + #include + #ifdef HAVE_SECURITY_PAM_MISC_H + # include +@@ -840,17 +841,20 @@ static void run_shell( + su->simulate_login ? " login" : "", + su->fast_startup ? " fast-start" : "")); + ++ char* tmp = xstrdup(shell); + if (su->simulate_login) { + char *arg0; + char *shell_basename; + +- shell_basename = basename(shell); ++ shell_basename = basename(tmp); + arg0 = xmalloc(strlen(shell_basename) + 2); + arg0[0] = '-'; + strcpy(arg0 + 1, shell_basename); + args[0] = arg0; +- } else +- args[0] = basename(shell); ++ } else { ++ args[0] = basename(tmp); ++ } ++ free(tmp); + + if (su->fast_startup) + args[argno++] = "-f"; diff --git a/srcpkgs/util-linux/template b/srcpkgs/util-linux/template index 358a75a3fb5..d2436dcab6e 100644 --- a/srcpkgs/util-linux/template +++ b/srcpkgs/util-linux/template @@ -2,7 +2,7 @@ # Keep this package sync with util-linux-common pkgname=util-linux version=2.38.1 -revision=6 +revision=7 build_style=gnu-configure configure_args="--exec-prefix=\${prefix} --enable-libuuid --disable-makeinstall-chown --enable-libblkid --enable-fsck --disable-rpath --enable-fs-paths-extra=/usr/sbin:/usr/bin