/* Get all the gid of the given uid */
- getpwuid_r(myuid, &pwd, buf, sizeof(buf), &userinfo);
+ if (getpwuid_r(myuid, &pwd, buf, sizeof(buf), &userinfo)) {
+ fprintf(stderr, "isadmin ERROR: cannot get password file entry\n");
+ return -1;
+ }
+
+ if (userinfo == NULL) {
+ fprintf(stderr, "isadmin ERROR: no matching password record\n");
+ return -1;
+ }
/* Need to call this function now to get the number of group to make the
malloc correctly sized */