Bug 17922 - [powerpc] getpwnam_r return value wrong for missing userid
Summary: [powerpc] getpwnam_r return value wrong for missing userid
Status: RESOLVED WORKSFORME
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-03 21:31 UTC by Bill Seurer
Modified: 2016-01-25 06:39 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Seurer 2015-02-03 21:31:47 UTC
#include <pwd.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main(void) {
  struct passwd pwd;
  struct passwd *pwdres;
  char buf[10000];
  int res = getpwnam_r("no-such-user", &pwd, buf, sizeof(buf), &pwdres);
  printf("res: %d\n", res);
  printf("(pwdres == 0): %d\n", (int)(pwdres == 0));
  return 0;
}


According to the getpwnam_r documentation 

On success, getpwnam_r() and getpwuid_r() return zero, and set *result to pwd. If no matching password record was found, these functions return 0 and store NULL in *result. In case of error, an error number is returned, and NULL is stored in *result. 

this program should print

res: 0
(pwdres == 0): 1

but on some power systems "res" is non-zero (specifically 2).  I tried it on several power systems and on some it worked properly and others not (both BE and LE).  I also tried it on an x86 system and it worked properly there.

It failed on systems with version 2.17 and 2.20 but worked on ones with 2.15 and 2.19 so I am not sure what releases are really affected.
Comment 1 Andreas Schwab 2015-02-03 22:01:46 UTC
You should verify that the affected systems are properly set up.
Comment 2 Florian Weimer 2015-02-06 09:57:44 UTC
Getting straces from a failure would be interesting.  2 is likely ENOENT.  Where does it come from?
Comment 3 Rajalakshmi 2016-01-20 05:09:54 UTC
Could not recreate it on power systems with glibc version 2.17(BE/LE) and version 2.20 (BE)
Comment 4 Rajalakshmi 2016-01-25 05:02:28 UTC
Could not recreate.