biod.pnpi.spb.ru
/
alexxy
/
gromacs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6c832fe
)
Fixed possible dereference of null pointer
author
Mark Abraham
<mark.j.abraham@gmail.com>
Thu, 11 Jul 2013 23:32:16 +0000
(
00:32
+0100)
committer
Gerrit Code Review
<gerrit@gerrit.gromacs.org>
Sun, 14 Jul 2013 03:28:00 +0000
(
05:28
+0200)
getpwuid() can return null. For example, Shun Sakuruba reported that
on Cray XE6 compute nodes have passwd.h, but users will not have
passwd entries.
Fixes #1301
Change-Id: I66e8064438fc02591629b0d381bc00afd06795c0
src/gmxlib/string2.c
patch
|
blob
|
history
diff --git
a/src/gmxlib/string2.c
b/src/gmxlib/string2.c
index 1b02ff798bed23dd0acb5f2685e83287b345880f..eadbf21a591804e985e429c36f6aae463e883821 100644
(file)
--- a/
src/gmxlib/string2.c
+++ b/
src/gmxlib/string2.c
@@
-244,7
+244,8
@@
void nice_header (FILE *out, const char *fn)
uid = getuid();
pw = getpwuid(uid);
gh = gethostname(buf, 255);
- user = pw->pw_name;
+ /* pw returns null on error (e.g. compute nodes lack /etc/passwd) */
+ user = pw ? pw->pw_name : unk;
#else
uid = 0;
gh = -1;