summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2014-07-21 21:29:22 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2014-07-22 21:31:42 -0400
commitfdadaf77ca45094e35ce724d7c91001f84b083c7 (patch)
tree8307bf236fb35fd0225e63e754ca71744cadef5a /mg.c
parent68419f9c61ef7c22b1225655e7e3b38058c70a71 (diff)
downloadperl-fdadaf77ca45094e35ce724d7c91001f84b083c7.tar.gz
Atol can be strtol in disguise, so grok_atou.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/mg.c b/mg.c
index 28ed1569bd..e1fc578f8b 100644
--- a/mg.c
+++ b/mg.c
@@ -2891,6 +2891,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
{
const char *p = SvPV_const(sv, len);
Groups_t *gary = NULL;
+ const char* endptr;
#ifdef _SC_NGROUPS_MAX
int maxgrp = sysconf(_SC_NGROUPS_MAX);
@@ -2902,19 +2903,20 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
while (isSPACE(*p))
++p;
- new_egid = (Gid_t)Atol(p);
+ new_egid = (Gid_t)grok_atou(p, &endptr);
for (i = 0; i < maxgrp; ++i) {
- while (*p && !isSPACE(*p))
- ++p;
+ if (endptr == NULL)
+ break;
+ p = endptr;
while (isSPACE(*p))
++p;
if (!*p)
break;
- if(!gary)
+ if (!gary)
Newx(gary, i + 1, Groups_t);
else
Renew(gary, i + 1, Groups_t);
- gary[i] = (Groups_t)Atol(p);
+ gary[i] = (Groups_t)grok_atou(p, &endptr);
}
if (i)
PERL_UNUSED_RESULT(setgroups(i, gary));