From b6c1a8579e059b99d8a8a56fa558592647f7de19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Fran=C3=A7ois?= Date: Fri, 2 Aug 2013 20:24:20 +0200 Subject: [PATCH] Fix segfaults * libmisc/setupenv.c: xstrdup the static char* temp_pw_dir / temp_pw_shell. That way we can continue to use pw_free() without segving. Thanks to Serge Hallyn for the patch. --- ChangeLog | 6 ++++++ libmisc/setupenv.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index af839cdf..b7a1e142 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-08-02 Nicolas François + + * libmisc/setupenv.c: xstrdup the static char* temp_pw_dir / + temp_pw_shell. That way we can continue to use pw_free() without + segving. Thanks to Serge Hallyn for the patch. + 2013-08-01 Yuri Kozlov * po/ru.po: completed translation diff --git a/libmisc/setupenv.c b/libmisc/setupenv.c index 992d3b81..28891ae1 100644 --- a/libmisc/setupenv.c +++ b/libmisc/setupenv.c @@ -228,7 +228,7 @@ void setup_env (struct passwd *info) exit (EXIT_FAILURE); } (void) puts (_("No directory, logging in with HOME=/")); - info->pw_dir = strdup(temp_pw_dir); + info->pw_dir = xstrdup (temp_pw_dir); } /* @@ -244,7 +244,7 @@ void setup_env (struct passwd *info) if ((NULL == info->pw_shell) || ('\0' == *info->pw_shell)) { static char temp_pw_shell[] = SHELL; - info->pw_shell = temp_pw_shell; + info->pw_shell = xstrdup (temp_pw_shell); } addenv ("SHELL", info->pw_shell);