mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-07-29 13:01:13 +03:00
Unbreak torture_config_make_absolute() on OpenBSD
The torture_config_make_absolute() and its _no_sshdir() version both segfault on OpenBSD. The reason for this is that the storage returned by getpwuid() is backed by mmap and is unapped by the getpwnam() call in ssh_path_expand_tilde(), so a later access to home segfaults. The possibility of this happening (getpwnam() overwriting values returned by getpwuid()) is explicitly called out in POSIX. A simple fix is to work with copies of username and homedir. Signed-off-by: Theo Buehler <tb@openbsd.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Jakub Jelen
parent
b43392c31d
commit
ccb8cf88c8
@ -2468,9 +2468,9 @@ static void torture_config_make_absolute_int(void **state, bool no_sshdir_fails)
|
||||
char *home = NULL;
|
||||
struct passwd *pw = getpwuid(getuid());
|
||||
assert_non_null(pw);
|
||||
user = pw->pw_name;
|
||||
user = strdup(pw->pw_name);
|
||||
assert_non_null(user);
|
||||
home = pw->pw_dir;
|
||||
home = strdup(pw->pw_dir);
|
||||
assert_non_null(home);
|
||||
#endif
|
||||
|
||||
@ -2528,6 +2528,8 @@ static void torture_config_make_absolute_int(void **state, bool no_sshdir_fails)
|
||||
snprintf(h, 256 - 1, "/etc/ssh/~%s/.ssh/config.d/*.conf", user);
|
||||
assert_string_equal(result, h);
|
||||
free(result);
|
||||
free(home);
|
||||
free(user);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user