Adding a slash between the directoryt and the file is a problem with
authorRichard Levitte <levitte@openssl.org>
Sat, 10 Jan 2004 18:04:36 +0000 (18:04 +0000)
committerRichard Levitte <levitte@openssl.org>
Sat, 10 Jan 2004 18:04:36 +0000 (18:04 +0000)
VMS.  The C RTL can handle it well if the "directory" is a logical
name with no colon, therefore ending being 'logname/file'.  However,
if the given logical names actually has a colon, or if you use a full
VMS-syntax directory, you end up with 'logname:/file' or
'dev:[dir1.dir2]/file', and that isn't handled in any good way.

So, on VMS, we need to check if the directory string ends with a
separator (one of ':', ']' or '>' (< and > can be used instead [ and
])), and handle that by not inserting anything between the directory
spec and the file name.  In all other cases, it's assumed the
directory spec is a logical name, so we need to place a colon between
it and the file.

Notified by Kevin Greaney <kevin.greaney@hp.com>.

crypto/x509/by_dir.c

index a9752d6a030bfea9d0d037b4f6a7bf8dc97c4918..c9bfe40ab69c433ba20f5bee84375461093f613f 100644 (file)
@@ -302,9 +302,38 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
                k=0;
                for (;;)
                        {
-                       BIO_snprintf(b->data,b->max,
-                                    "%s/%08lx.%s%d",ctx->dirs[i],h,
-                                    postfix,k);
+                       char c = '/';
+#ifdef OPENSSL_SYS_VMS
+                       char c = ctx->dirs[i][strlen(ctx->dirs[i])-1];
+                       if (c != ':' && c != '>' && c != ']')
+                               {
+                               /* If no separator is present, we assume the
+                                  directory specifier is a logical name, and
+                                  add a colon.  We really should use better
+                                  VMS routines for merging things like this,
+                                  but this will do for now...
+                                  -- Richard Levitte */
+                               c = ':';
+                               }
+                       else
+                               {
+                               c = '\0';
+                               }
+#endif
+                       if (c == '\0')
+                               {
+                               /* This is special.  When c == '\0', no
+                                  directory separator should be added. */
+                               BIO_snprintf(b->data,b->max,
+                                       "%s%08lx.%s%d",ctx->dirs[i],h,
+                                       postfix,k);
+                               }
+                       else
+                               {
+                               BIO_snprintf(b->data,b->max,
+                                       "%s%c%08lx.%s%d",ctx->dirs[i],c,h,
+                                       postfix,k);
+                               }
                        k++;
                        if (stat(b->data,&st) < 0)
                                break;