• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
getpwnam("") && getgrnam("") returns an found entry but not NULL on Mountain Lion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getpwnam("") && getgrnam("") returns an found entry but not NULL on Mountain Lion


  • Subject: getpwnam("") && getgrnam("") returns an found entry but not NULL on Mountain Lion
  • From: Reeze Xia <email@hidden>
  • Date: Fri, 10 Aug 2012 17:09:35 +0800

Thanks Andreas & Stephen,

I'v fill a bug report: #12065154  in bugreport.apple.com

Thanks

CC email@hidden

在 2012年8月10日星期五,下午4:11,Andreas Fink 写道:

I can confirm your finding.
Below code

#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



On 10.08.2012, at 08:40, Reeze Xia <email@hidden> wrote:

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-kernel mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >getpwnam("") && getgrnam("") returns an found entry but not NULL, is it a bug? (From: Reeze Xia <email@hidden>)

  • Prev by Date: Re: getpwnam("") && getgrnam("") returns an found entry but not NULL, is it a bug?
  • Next by Date: ThunderBolt....
  • Previous by thread: Re: getpwnam("") && getgrnam("") returns an found entry but not NULL, is it a bug?
  • Next by thread: ThunderBolt....
  • Index(es):
    • Date
    • Thread