From: perlbug-followup@perl.org Date: Fri, 23 Oct 2009 15:20:38 +0000 (-0700) Subject: mg.c uses a fixed NGROUPS contant X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fb4089e0451edf57bb8c2f8e853074872a4ac7d3;p=p5sagit%2Fp5-mst-13.2.git mg.c uses a fixed NGROUPS contant # New Ticket Created by casper.dik@sun.com # Please include the string: [perl #69977] # in the subject line of all future correspondence about this issue. # This is a bug report for perl from casper.dik@sun.com, generated with the help of perlbug 1.36 running under perl 5.10.0. ----------------------------------------------------------------- [Please enter your report here] In mg.c NGROUPS is defined as follows: #if defined(HAS_SETGROUPS) # ifndef NGROUPS # define NGROUPS 32 # endif #endif and uses it later here: 2632 #ifdef HAS_SETGROUPS 2633 { 2634 const char *p = SvPV_const(sv, len); 2635 Groups_t *gary = NULL; 2636 2637 while (isSPACE(*p)) 2638 ++p; 2639 PL_egid = Atol(p); 2640 for (i = 0; i < NGROUPS; ++i) { 2641 while (*p && !isSPACE(*p)) 2642 ++p; 2643 while (isSPACE(*p)) 2644 ++p; 2645 if (!*p) 2646 break; 2647 if(!gary) 2648 Newx(gary, i + 1, Groups_t); 2649 else 2650 Renew(gary, i + 1, Groups_t); 2651 gary[i] = Atol(p); 2652 } 2653 if (i) 2654 (void)setgroups(i, gary); 2655 Safefree(gary); 2656 } 2657 #else /* HAS_SETGROUPS */ This should be changed as follows --- diff --git a/mg.c b/mg.c index 05f8cd9..aaed62d 100644 --- a/mg.c +++ b/mg.c @@ -2667,11 +2667,19 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) { const char *p = SvPV_const(sv, len); Groups_t *gary = NULL; +#ifdef _SC_NGROUPS_MAX + int maxgrp = sysconf(_SC_NGROUPS_MAX); + + if (maxgrp < 0) + maxgrp = NGROUPS; +#else + int maxgrp = NGROUPS; +#endif while (isSPACE(*p)) ++p; PL_egid = Atol(p); - for (i = 0; i < NGROUPS; ++i) { + for (i = 0; i < maxgrp; ++i) { while (*p && !isSPACE(*p)) ++p; while (isSPACE(*p))