]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
testutil: teach test_mk_file_path() how to merge VMS file specs
authorRichard Levitte <levitte@openssl.org>
Tue, 22 Jun 2021 06:03:47 +0000 (08:03 +0200)
committerRichard Levitte <levitte@openssl.org>
Sat, 26 Jun 2021 04:43:08 +0000 (06:43 +0200)
This isn't a full solution, it only handles current use cases.

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15823)

test/testutil/driver.c

index 702f7b2caa715d50e30a80292cdba590aeb4cc53..f91d1ab9325c7da1d5fca19a6f8cc3b2d29616b3 100644 (file)
@@ -436,13 +436,36 @@ char *test_mk_file_path(const char *dir, const char *file)
     const char *sep = "/";
 # else
     const char *sep = "";
+    char *dir_end;
+    char dir_end_sep;
 # endif
     size_t len = strlen(dir) + strlen(sep) + strlen(file) + 1;
     char *full_file = OPENSSL_zalloc(len);
 
     if (full_file != NULL) {
-        OPENSSL_strlcpy(full_file, dir, len);
-        OPENSSL_strlcat(full_file, sep, len);
+        if (dir != NULL && dir[0] != '\0') {
+            OPENSSL_strlcpy(full_file, dir, len);
+# ifdef OPENSSL_SYS_VMS
+            /*
+             * If |file| contains a directory spec, we need to do some
+             * careful merging.
+             * "vol:[dir.dir]" + "[.certs]sm2-root.crt" should become
+             * "vol:[dir.dir.certs]sm2-root.crt"
+             */
+            dir_end = &full_file[strlen(full_file) - 1];
+            dir_end_sep = *dir_end;
+            if ((dir_end_sep == ']' || dir_end_sep == '>')
+                && (file[0] == '[' || file[0] == '<')) {
+                file++;
+                if (file[0] == '.')
+                    *dir_end = '\0';
+                else
+                    *dir_end = '.';
+            }
+#else
+            OPENSSL_strlcat(full_file, sep, len);
+#endif
+        }
         OPENSSL_strlcat(full_file, file, len);
     }