diff options
author | Craig A. Berry <craigberry@mac.com> | 2012-08-10 21:25:09 -0500 |
---|---|---|
committer | Craig A. Berry <craigberry@mac.com> | 2012-08-10 21:25:09 -0500 |
commit | 155f4c250a9701391303ae7e38650ccff6f43b78 (patch) | |
tree | 60b2d6faf22e11f8efbb903d383b79caabc2cf6f /pp_ctl.c | |
parent | 1ebd3007591c91215bcc334318e0485e73e6f13f (diff) | |
download | perl-155f4c250a9701391303ae7e38650ccff6f43b78.tar.gz |
pp_require thread safety for VMS.
When we translate path names of required modules into Unix format,
we haven't (recently) been using the optional second argument to
the translation routines,[1] an argument that supplies a buffer for
the translation. That causes them to use a static buffer. Which
means that if two or more different threads are doing a require
operation at the same time, they will be blindly sharing the same
buffer.
So allocate buffers as we need them and make them mortal so they
will go away at the next state transition.
[1] Use of an automatic variable for the buffer was removed way
back in 46fc3d4c69a0ad.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -3580,6 +3580,9 @@ PP(pp_require) STRLEN unixlen; #ifdef VMS int vms_unixname = 0; + char *unixnamebuf; + char *unixdir; + char *unixdirbuf; #endif const char *tryname = NULL; SV *namesv = NULL; @@ -3665,7 +3668,9 @@ PP(pp_require) * To prevent this, the key must be stored in UNIX format if the VMS * name can be translated to UNIX. */ - if ((unixname = tounixspec(name, NULL)) != NULL) { + + if ((unixnamebuf = SvPVX(sv_2mortal(newSVpv("", VMS_MAXRSS-1)))) + && (unixname = tounixspec(name, unixnamebuf)) != NULL) { unixlen = strlen(unixname); vms_unixname = 1; } @@ -3840,8 +3845,8 @@ PP(pp_require) } #ifdef VMS - char *unixdir; - if ((unixdir = tounixpath(dir, NULL)) == NULL) + if (((unixdirbuf = SvPVX(sv_2mortal(newSVpv("", VMS_MAXRSS-1)))) == NULL) + || ((unixdir = tounixpath(dir, unixdirbuf)) == NULL)) continue; sv_setpv(namesv, unixdir); sv_catpv(namesv, unixname); |