Project

General

Profile

Bug #1301

nice_header() in src/gmxlib/string2.c may dereference NULL pointer

Added by Shun Sakuraba almost 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
core library
Target version:
Affected version - extra info:
Affected version:
Difficulty:
uncategorized
Close

Description

If there exists pwd.h, but the user id cannot be found in password entry, getpwuid() returns NULL pointer. Since the user name is dereferenced without any test, this leads to null pointer dereference (and segmentation fault).

In src/gmxlib/string2.c,

    243 #ifdef HAVE_PWD_H
    244     uid  = getuid();
    245     pw   = getpwuid(uid);
    246     gh   = gethostname(buf, 255);
    247     user = pw->pw_name;
    248 #else

Fix is trivial:

    user = (pw ? pw->pw_name : unk);

Associated revisions

Revision 5c88c2b9 (diff)
Added by Mark Abraham almost 4 years ago

Fixed possible dereference of null pointer

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

History

#1 Updated by Shun Sakuraba almost 4 years ago

Note: the problem happened on Cray XE6 system, where the "compute nodes" do not have password entry of users.

#2 Updated by Mark Abraham almost 4 years ago

  • Status changed from New to Fix uploaded
  • Target version set to 4.6.4

#3 Updated by Mark Abraham over 3 years ago

  • Status changed from Fix uploaded to Resolved
  • % Done changed from 0 to 100

#4 Updated by Mark Abraham over 3 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF