Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Apr 1997 15:36:16 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        davidn@unique.usn.blaze.net.au, freebsd-bugs@freefall.freebsd.org
Subject:   Re: bin/3242: incorrect prototype for initgroups
Message-ID:  <199704130536.PAA20961@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
> >      int
> >      initgroups(const char *name, int basegid)
> > 
> >                                   ^^^ what about gid_t here?
> >                                     and in the function definition.
> 
> It should be the same type that is used in pwd.h for
> pwd.pw_gid which, currently, is 'int'.

pwd.h is just broken.  initgroups() is consistent with getgrouplist(),
which still uses ints for the array of groups.  initgroups() constructs
an array of ints and passes it to setgroups() which expects an array
of gid_t's.  On systems with 32-bit ints, the types only differ in
signedness.  gcc -Wall doesn't warn about this.  All this should be
fixed.

> I believe that Bruce was looking into this one, since it
> had to do with the self-sufficiency of headers, but I've
> just noticed that both files now include sys/types.h
> unconditionally. Of course the type of pw_uid is also part
> of the question.

<unistd.h> and <pwd.h> include <sys/types.h> but <grp.h> doesn't.
grp.gr_gid has the same bug as pwd.pw_gid.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199704130536.PAA20961>