From: Richard Levitte Date: Tue, 22 Jun 2021 06:03:47 +0000 (+0200) Subject: testutil: teach test_mk_file_path() how to merge VMS file specs X-Git-Tag: openssl-3.0.0-beta2~176 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01b093aaeeb15d0a2ca0b5f8c100109821f884fb;p=thirdparty%2Fopenssl.git testutil: teach test_mk_file_path() how to merge VMS file specs This isn't a full solution, it only handles current use cases. Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/15823) --- diff --git a/test/testutil/driver.c b/test/testutil/driver.c index 702f7b2caa7..f91d1ab9325 100644 --- a/test/testutil/driver.c +++ b/test/testutil/driver.c @@ -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); }