o_time.c: use gmtime_s with MSVC
[openssl.git] / crypto / dso / dso_vms.c
index 511858a68197b3d1609f27796a967a9cb151b6fa..1efd84b94539ecbba62fcb34107d5b431f2cc74b 100644 (file)
@@ -1,4 +1,4 @@
-/* dso_vms.c -*- mode:C; c-file-style: "eay" -*- */
+/* dso_vms.c */
 /*
  * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project
  * 2000.
@@ -172,29 +172,30 @@ static int vms_load(DSO *dso)
 # endif                         /* __INITIAL_POINTER_SIZE == 64 */
 
     const char *sp1, *sp2;      /* Search result */
+    const char *ext = NULL;    /* possible extension to add */
 
     if (filename == NULL) {
         DSOerr(DSO_F_VMS_LOAD, DSO_R_NO_FILENAME);
         goto err;
     }
 
-        /*-
-         * A file specification may look like this:
-         *
-         *      node::dev:[dir-spec]name.type;ver
-         *
-         * or (for compatibility with TOPS-20):
-         *
-         *      node::dev:<dir-spec>name.type;ver
-         *
-         * and the dir-spec uses '.' as separator.  Also, a dir-spec
-         * may consist of several parts, with mixed use of [] and <>:
-         *
-         *      [dir1.]<dir2>
-         *
-         * We need to split the file specification into the name and
-         * the rest (both before and after the name itself).
-         */
+    /*-
+     * A file specification may look like this:
+     *
+     *      node::dev:[dir-spec]name.type;ver
+     *
+     * or (for compatibility with TOPS-20):
+     *
+     *      node::dev:<dir-spec>name.type;ver
+     *
+     * and the dir-spec uses '.' as separator.  Also, a dir-spec
+     * may consist of several parts, with mixed use of [] and <>:
+     *
+     *      [dir1.]<dir2>
+     *
+     * We need to split the file specification into the name and
+     * the rest (both before and after the name itself).
+     */
     /*
      * Start with trying to find the end of a dir-spec, and save the position
      * of the byte after in sp1
@@ -213,12 +214,20 @@ static int vms_load(DSO *dso)
         sp1++;                  /* The byte after the found character */
     /* Now, let's see if there's a type, and save the position in sp2 */
     sp2 = strchr(sp1, '.');
+    /*
+     * If there is a period and the next character is a semi-colon,
+     * we need to add an extension
+     */
+    if (sp2 != NULL && sp2[1] == ';')
+        ext = ".EXE";
     /*
      * If we found it, that's where we'll cut.  Otherwise, look for a version
      * number and save the position in sp2
      */
-    if (sp2 == NULL)
+    if (sp2 == NULL) {
         sp2 = strchr(sp1, ';');
+        ext = ".EXE";
+    }
     /*
      * If there was still nothing to find, set sp2 to point at the end of the
      * string
@@ -244,6 +253,11 @@ static int vms_load(DSO *dso)
 
     strncpy(p->imagename, filename, sp1 - filename);
     p->imagename[sp1 - filename] = '\0';
+    if (ext) {
+        strcat(p->imagename, ext);
+        if (*sp2 == '.')
+            sp2++;
+    }
     strcat(p->imagename, sp2);
 
     p->filename_dsc.dsc$w_length = strlen(p->filename);
@@ -525,7 +539,8 @@ static char *vms_name_converter(DSO *dso, const char *filename)
 {
     int len = strlen(filename);
     char *not_translated = OPENSSL_malloc(len + 1);
-    strcpy(not_translated, filename);
+    if (not_translated)
+        strcpy(not_translated, filename);
     return (not_translated);
 }