summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>2015-03-10 22:28:25 +0000
committerHugo van der Sanden <hv@crypt.org>2015-03-10 22:28:25 +0000
commit0635704a987a9ec0c9983c4b01b19624fafe668a (patch)
treef4943c605b07696fc911fc5581fafb06f3d860d3 /mg.c
parentcc404f89bd025d82e844e94296b850d14001fe91 (diff)
downloadperl-0635704a987a9ec0c9983c4b01b19624fafe668a.tar.gz
mg.c:Perl_magic_set: don't use 0 as "failed" gid_t
For [perl #123814] we added checking for grok_* parse failures in magic_set for $), but used 0 as the placeholder result in those cases (since we don't have an effective way to report an error for this). (Gid_t)(-1) is a safer placeholder, since on many systems that'll map to an explicit bad group id.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/mg.c b/mg.c
index 2ed1764a06..ee3cf29aa1 100644
--- a/mg.c
+++ b/mg.c
@@ -3013,6 +3013,12 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
}
case ')':
{
+/* (hv) best guess: maybe we'll need configure probes to do a better job,
+ * but you can override it if you need to.
+ */
+#ifndef INVALID_GID
+#define INVALID_GID ((Gid_t)-1)
+#endif
/* XXX $) currently silently ignores failures */
Gid_t new_egid;
#ifdef HAS_SETGROUPS
@@ -3035,7 +3041,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
if (grok_atoUV(p, &uv, &endptr))
new_egid = (Gid_t)uv;
else {
- new_egid = 0; /* XXX is this safe? */
+ new_egid = INVALID_GID;
endptr = NULL;
}
for (i = 0; i < maxgrp; ++i) {
@@ -3053,7 +3059,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
if (grok_atoUV(p, &uv, &endptr))
gary[i] = (Groups_t)uv;
else {
- gary[i] = 0; /* XXX is this safe? */
+ gary[i] = INVALID_GID;
endptr = NULL;
}
}