This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Handle invalid directory spec with EFS in pathify_dirspec.
authorCraig A. Berry <craigberry@mac.com>
Sun, 25 Nov 2012 00:46:44 +0000 (18:46 -0600)
committerCraig A. Berry <craigberry@mac.com>
Sun, 25 Nov 2012 01:17:19 +0000 (19:17 -0600)
When Extended Filename Syntax is enabled on VMS (which is not [yet]
the default), we were allowing invalid directory specifications
consisting of a .DIR extension but some version other than ;1 to
be passed through.

Now we flag that as an invalid directory just as we were doing
without EFS.  This gets a test passing in vms/ext/filespec.t that
was failing under EFS.

vms/vms.c

index b08ff18..3b9b032 100644 (file)
--- a/vms/vms.c
+++ b/vms/vms.c
@@ -6467,13 +6467,26 @@ static char * int_pathify_dirspec_simple(const char * dir, char * buf,
             len += n_len;
             if (e_len > 0) {
                 if (decc_efs_charset) {
-                    buf[len] = '^';
-                    len++;
-                    memcpy(&buf[len], e_spec, e_len);
-                    len += e_len;
-                } else {
-                    set_vaxc_errno(RMS$_DIR);
-                    set_errno(ENOTDIR);
+                    if (e_len == 4 
+                        && (toupper(e_spec[1]) == 'D')
+                        && (toupper(e_spec[2]) == 'I')
+                        && (toupper(e_spec[3]) == 'R')) {
+
+                        /* Corner case: directory spec with invalid version.
+                         * Valid would have followed is_dir path above.
+                         */
+                        SETERRNO(ENOTDIR, RMS$_DIR);
+                        return NULL;
+                    }
+                    else {
+                        buf[len] = '^';
+                        len++;
+                        memcpy(&buf[len], e_spec, e_len);
+                        len += e_len;
+                    }
+                }
+                else {
+                    SETERRNO(ENOTDIR, RMS$_DIR);
                     return NULL;
                 }
             }