Re: max uid value

Tomasz Kłoczko <[email protected]> Mon, 24 Jul 2006 16:48:10 +0200
Newsgroups gmane.linux.pld.shadow.general
Message-ID <1153752490.1802.6.camel@kloczek01>
Dnia 24-07-2006, pon o godzinie 06:10 -0700, Ulrich Drepper napisał(a):
> Programs can easily define the value themselves or simply add a
> trivial test for negative values.  The above value would only be
> useful if you'd do your computations with an unsigned or a larger
> type. Just don't do it.  Use [gu]id_t and test for negative values.
> That's the simplest wayto do it. 

(please fix me if I'm wrong)
And this is IMO core of problem because in current glibc [gu]id_t it is
unsignet 32bit:

$ grep ID_T /usr/include/bits/typesizes.h 
#define __UID_T_TYPE            __U32_TYPE  <== this
#define __GID_T_TYPE            __U32_TYPE  <== and this
#define __PID_T_TYPE            __S32_TYPE
#define __ID_T_TYPE             __U32_TYPE
#define __CLOCKID_T_TYPE        __S32_TYPE
#define __FSID_T_TYPE           struct { int __val[2]; }

__[GU]ID_T_TYPE types are used in bits/types.h for define __[ug]id_t and __[gu]id_t in
unistd.h are used for define [gu]id_t types.

So code like:

	gid_t gid;
        char *errptr;

	gid = strtoul (grname, &errptr, 10);
	if (*errptr || errno == ERANGE || gid < 0) {
		<error>
	}

always will pass without touching <error> code for grname="-1"
(it is not possible correctly test now for negative [gu]id values using only 32bit variables).

$ rpm -qf /usr/include/bits/typesizes.h
glibc-headers-2.4.90-13

kloczek