diff cli-runopts.c @ 961:a4032b946355

Be a bit safer in case pw_name doesn't exist
author Matt Johnston <matt@ucc.asn.au>
date Wed, 06 Aug 2014 22:10:57 +0800
parents 1bf92da7a2a0
children 6fb4c010c448
line wrap: on
line diff
--- a/cli-runopts.c	Wed Aug 06 22:08:16 2014 +0800
+++ b/cli-runopts.c	Wed Aug 06 22:10:57 2014 +0800
@@ -683,11 +683,13 @@
 	uid = getuid();
 
 	pw = getpwuid(uid);
-	if (pw == NULL || pw->pw_name == NULL) {
+	if (pw && pw->pw_name != NULL) {
+		cli_opts.own_user = m_strdup(pw->pw_name);
+	} else {
 		dropbear_log(LOG_INFO, "Warning: failed to identify current user. Trying anyway.");
+		cli_opts.own_user = m_strdup("unknown");
 	}
 
-	cli_opts.own_user = m_strdup(pw->pw_name);
 }
 
 #ifdef ENABLE_CLI_ANYTCPFWD