| Store | Cart

[perl #134194] Cannot assign multiple groups to $EFFECTIVE_GROUP_ID / $EGID / $)

From: Tony Cook via RT <perl...@perl.org>
Wed, 12 Jun 2019 22:23:50 -0700
On Wed, 12 Jun 2019 17:54:36 -0700, dev...@sumpfralle.de wrote:
> The behaviour of "$)" ($EFFECTIVE_GROUP_ID) has changed between 5.28> and 5.30:> > > perl 5.28> > # perl -E 'say $); $)="104 104"; say $); say $! '> 0 0 1 2 3 4 6 10 11 26 27> 104 104> > > perl 5.30> > # perl -E 'say $); $)="104 104"; say $); say $! '> 0 0 1 2 3 4 6 10 11 26 27> 104 0 1 2 3 4 6 10 11 26 27> Invalid argument> > (example by "bes-internal"; see> https://github.com/munin-monitoring/munin/issues/1202#issuecomment-> 501498851)> > > Specifying only a single number does not cause an error.> The man page (perlvar) describes that multiple values (separated by> space) are> allowed. Thus the new behaviour of 5.30 seems to be unintended.

The attached seems to fix it for me:

  # ./perl -e '$) = "0 0 1000"; system "id"'
  uid=0(root) gid=0(root) groups=0(root),1000(tony)

There's no tests for setting $) that I can find and I'm not sure it's practical to add one.

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=134194

From 4fe915fb80c78fa98164942ad75f29f44400898d Mon Sep 17 00:00:00 2001
From: Tony Cook <t...@develop-help.com>
Date: Thu, 13 Jun 2019 15:14:40 +1000
Subject: (perl #134194) fix parsing supplemental groups from $)

For example, if parsing the second number from:

  "123 456 789"

endptr would be left pointing at the first space, while we try to start
parsing at the "4", which grok_atoUV() would reject.
---
 mg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mg.c b/mg.c
index f4783fb68a..db831d8e86 100644
--- a/mg.c
+++ b/mg.c
@@ -3178,7 +3178,8 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
 	{
 	    const char *p = SvPV_const(sv, len);
             Groups_t *gary = NULL;
-            const char* endptr = p + len;
+            const char * const end = p + len;
+            const char* endptr = end;
             UV uv;
 #ifdef _SC_NGROUPS_MAX
            int maxgrp = sysconf(_SC_NGROUPS_MAX);
@@ -3209,6 +3210,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
                     Newx(gary, i + 1, Groups_t);
                 else
                     Renew(gary, i + 1, Groups_t);
+                endptr = end;
                 if (grok_atoUV(p, &uv, &endptr))
                     gary[i] = (Groups_t)uv;
                 else {
-- 
2.11.0


Recent Messages in this Thread
Tony Cook via RT Jun 13, 2019 05:23 am