Revert "GH614: Use memcpy()/strdup() when possible"
[openssl.git] / crypto / dso / dso_dlfcn.c
index a4b0cdd95b5d78c16fd9c224f6ea5ceac392c343..e2aa76eb65d3be8f13ccb56fcbaeb17b19cd6b05 100644 (file)
@@ -196,21 +196,23 @@ static char *dlfcn_merger(DSO *dso, const char *filespec1,
      * if the second file specification is missing.
      */
     if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) {
-        merged = OPENSSL_strdup(filespec1);
+        merged = OPENSSL_malloc(strlen(filespec1) + 1);
         if (merged == NULL) {
             DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE);
             return (NULL);
         }
+        strcpy(merged, filespec1);
     }
     /*
      * If the first file specification is missing, the second one rules.
      */
     else if (!filespec1) {
-        merged = OPENSSL_strdup(filespec2);
+        merged = OPENSSL_malloc(strlen(filespec2) + 1);
         if (merged == NULL) {
             DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE);
             return (NULL);
         }
+        strcpy(merged, filespec2);
     } else {
         /*
          * This part isn't as trivial as it looks.  It assumes that the