]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tty-ask-password-agent: use free_and_strdup_warn() for arg_device 36198/head
authorMike Yuan <me@yhndnzj.com>
Tue, 28 Jan 2025 01:07:16 +0000 (02:07 +0100)
committerMike Yuan <me@yhndnzj.com>
Tue, 28 Jan 2025 01:23:57 +0000 (02:23 +0100)
Follow-up for 68cf1fc34d3e86a664fb948d413e1db4a24e16dd

Fixes CID#1590840

src/tty-ask-password-agent/tty-ask-password-agent.c

index 26c135a45f3f8ab90fffb33cb9714362efc6777e..6950a8697ee55ba9b1370b67e55fe282352c7a3e 100644 (file)
@@ -495,7 +495,7 @@ static int parse_argv(int argc, char *argv[]) {
                 {}
         };
 
-        int c;
+        int r, c;
 
         assert(argc >= 0);
         assert(argv);
@@ -537,9 +537,9 @@ static int parse_argv(int argc, char *argv[]) {
                                         return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                                                "Empty console device path is not allowed.");
 
-                                arg_device = strdup(optarg);
-                                if (!arg_device)
-                                        return log_oom();
+                                r = free_and_strdup_warn(&arg_device, optarg);
+                                if (r < 0)
+                                        return r;
                         }
                         break;