I can confirm your finding.
#include <sys/types.h>
#include <stdio.h>
#include <pwd.h>
#include <uuid/uuid.h>
#include <stdlib.h>
#define MAYBE_NULL_STRING(a) (a ? a : "(NULL)")
extern int errno;
int main(int argc, char *argv[])
{
errno = 0;
struct passwd *pwdstruct = getpwnam("");
printf("errno = %d\n",errno);
if(pwdstruct == NULL)
{
printf("pwdstruct == NULL\n");
exit(0);
}
printf("pw_name: %s\n",MAYBE_NULL_STRING(pwdstruct->pw_name));
printf("pw_passwd: %s\n",MAYBE_NULL_STRING(pwdstruct->pw_passwd));
printf("pw_uid: %d\n",pwdstruct->pw_uid);
printf("pw_gid: %d\n",pwdstruct->pw_gid);
}
produces
$ ./a.out
errno = 0
pw_name:
pw_passwd:
pw_uid: 0
pw_gid: 0
I guess you should file a bugreport. It is at least conflicting with the manpage of getpwnam
Hi, guy,
I don't know if this is the right mailing list to post, if not please forgive me plz :)
After upgrade to Mountain Lion: function getpwname() && getgrname("") returns an entry but not NULL.
Does Mountain lion have a hidden user&group ? I thought it's a bug.
getpwnanm("") returns a entry with empty name but uid=0 gid=0, 0 is root users uid. this seems have security problem.
Can someone verify this for me please.
Thanks for your time
-----------------
The below is reproducible code.
#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>
#include <unistd.h>
#include <stdlib.h>
int main() {
int ret;
if(getgrnam("")) {
printf("Found empty group\n");
} else {
printf("Right\n");
}
return 0;
}
Expected Results:
Right
Actual Results:
Found empty group
--
reeze |
http://reeze.cn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden