[PATCH] NGROUPS_MAX will cause stack overflow
Peter S. Mazinger
ps.m at gmx.net
Wed Dec 28 22:03:28 UTC 2005
On Wed, 28 Dec 2005, Aubrey wrote:
> On 12/27/05, Mike Frysinger <vapier at gentoo.org> wrote:
> > thanks, ive committed a slightly different version of this as well
> > -mike
> >
> Oops, just now I found my patch has problem when malloc(0). The
> original implement will return a valid value when n=0. But my patch
> depents on the behavior of malloc. When uClibc option [Malloc returns
> live pointer for malloc(0)] is enabled, my patch will return a valid
> value. But when it is disabled, my patch will return (-1).
>
> This case should be handled like this:
>
> - if(kernel_groups=(__kernel_gid_t *)malloc(sizeof(__kernel_gid_t)*n) == NULL){
> +if( (kernel_groups=(__kernel_gid_t *)malloc(sizeof(__kernel_gid_t)*n) == NULL)
> + && n!=0 ) {
>
> __set_errno(EINVAL);
> return -1;
> }
> Now it should be exactly correct.
> We also tested it and worked fine.
>
> Thanks
> -Aubrey
Shouldn't this depend on MALLOC_GLIBC_COMPAT?
Peter
--
Peter S. Mazinger <ps dot m at gmx dot net> ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08 BB6E C389 975E A5F0 59F2
More information about the uClibc
mailing list