]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: Skip optarg duplication
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 11 Apr 2026 18:38:56 +0000 (20:38 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 12 Apr 2026 11:08:38 +0000 (13:08 +0200)
Supplying -s multiple times leaks memory. The given optarg is
eventually set in a struct passwd and line 1657 is the only alternative
that sets a constant string, i.e. the data is neither freed nor
modified.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
login-utils/login.c

index 0f303e7534a66db05e896e40d3d44593ed9c361e..d9e93d0dd178e0cfe0c83280d7bce35915d3301d 100644 (file)
@@ -1446,7 +1446,7 @@ static void initialize(int argc, char **argv, struct login_context *cxt)
                        break;
 
                case 's':
-                       cxt->shell_arg = xstrdup(optarg);
+                       cxt->shell_arg = optarg;
                        break;
 
                case 'V':