summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2022-04-20 06:55:45 +0200
committerKarl Williamson <khw@cpan.org>2022-05-28 15:01:00 -0600
commit92ec2fce1aace295365d7d86c61c98df8202fc9d (patch)
tree108331ffd38dba55a6699ab5e0beeed2686131f8 /mg.c
parent274b07827bad27b0561a9a8b751138474115012d (diff)
downloadperl-92ec2fce1aace295365d7d86c61c98df8202fc9d.tar.gz
Revert "Revert "mg.c, Cwd.pm - Empty path is the same as "." which is forbidden under taint""
This reverts commit 9eb153ffbbde62558146e8f9b837034f42878e13. The patch this unreverts was accidentally pushed to blead without going through PR or smoke process which it really needs. This patch exists so it can go through that process.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/mg.c b/mg.c
index 7a4727cedf..831e25117f 100644
--- a/mg.c
+++ b/mg.c
@@ -1356,6 +1356,15 @@ Perl_magic_setenv(pTHX_ SV *sv, MAGIC *mg)
const char path_sep = ':';
#endif
+#ifndef __VMS
+ /* Does this apply for VMS?
+ * Empty PATH on linux is treated same as ".", which is forbidden
+ * under taint. So check if the PATH variable is empty. */
+ if (!len) {
+ MgTAINTEDDIR_on(mg);
+ return 0;
+ }
+#endif
/* set MGf_TAINTEDDIR if any component of the new path is
* relative or world-writeable */
while (s < strend) {
@@ -1372,7 +1381,8 @@ Perl_magic_setenv(pTHX_ SV *sv, MAGIC *mg)
/* Using Unix separator, e.g. under bash, so act line Unix */
|| (PL_perllib_sep == ':' && *tmpbuf != '/')
#else
- || *tmpbuf != '/' /* no starting slash -- assume relative path */
+ || *tmpbuf != '/' /* no starting slash -- assume relative path */
+ || s == strend /* trailing empty component -- same as "." */
#endif
|| (PerlLIO_stat(tmpbuf, &st) == 0 && (st.st_mode & 2)) ) {
MgTAINTEDDIR_on(mg);