]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/su.c: Use const_cast() to silence -Wincompatible-pointer-types-discards-qualifiers
authorAlejandro Colomar <alx@kernel.org>
Mon, 22 Jan 2024 21:52:59 +0000 (22:52 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 26 Jan 2024 08:40:10 +0000 (09:40 +0100)
argv is passed to execve(3), which for historic reasons is non-const,
but doesn't modify the strings.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/su.c

index ba13a67ddd67e25ae35d114c4fd26e724b69a0f9..07f0eea1916ad8791dc3e49eae219d3c660374ce 100644 (file)
--- a/src/su.c
+++ b/src/su.c
@@ -48,6 +48,7 @@
 
 #include "alloc.h"
 #include "attr.h"
+#include "cast.h"
 #include "prototypes.h"
 #include "defines.h"
 #include "pwauth.h"
@@ -1228,7 +1229,7 @@ int main (int argc, char **argv)
                 * Use the shell and create an argv
                 * with the rest of the command line included.
                 */
-               argv[-1] = cp;
+               argv[-1] = const_cast(char *, cp);
                execve_shell (shellstr, &argv[-1], environ);
                err = errno;
                (void) fprintf (stderr,