user-util: return malloc'ed strings in get_user_creds

get_user_creds would use getpwnam() and then returns strings pointing
into the static buffer. This seems very iffy. Let's duplicate the
strings properly
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-05-21 18:02:05 +02:00
parent 3ecd6b69cf
commit c83ff0e58d
21 changed files with 176 additions and 203 deletions
+1 -1
View File
@@ -196,7 +196,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
break;
OPTION_LONG("uid", "USER", "Set user to send from"):
r = get_user_creds(&opts.arg, &arg_uid, &arg_gid, NULL, NULL, 0);
r = get_user_creds(opts.arg, /* flags= */ 0, NULL, &arg_uid, &arg_gid, NULL, NULL);
if (r == -ESRCH) /* If the user doesn't exist, then accept it anyway as numeric */
r = parse_uid(opts.arg, &arg_uid);
if (r < 0)