Don't try to dereference pw when it's NULL.

Fixes Coverity CID 900.
This commit is contained in:
peter 2006-03-18 00:32:34 +00:00
parent 9bccbf4462
commit dfd65180e1
1 changed files with 5 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: systrace.c,v 1.31 2005/06/25 18:47:42 elad Exp $ */
/* $NetBSD: systrace.c,v 1.32 2006/03/18 00:32:34 peter Exp $ */
/* $OpenBSD: systrace.c,v 1.32 2002/08/05 23:27:53 provos Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
@ -84,12 +84,12 @@ systrace_parameters(void)
iamroot = getuid() == 0;
/* Find out current username. */
if ((pw = getpwuid(uid)) == NULL)
if ((pw = getpwuid(uid)) == NULL) {
snprintf(username, sizeof(username), "uid %u", uid);
else
} else {
strlcpy(username, pw->pw_name, sizeof(username));
strlcpy(home, pw->pw_dir, sizeof(home));
strlcpy(home, pw->pw_dir, sizeof(home));
}
/* Determine current working directory for filtering */
if (getcwd(cwd, sizeof(cwd)) == NULL)