diff options
author | Rich Salz <rsalz@openssl.org> | 2017-09-14 16:13:53 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-09-14 16:13:53 -0400 |
commit | 297002a332302a102a9fd802012f12ba2ad056c1 (patch) | |
tree | 31b7fe39f049247b811335555672a078661218e5 /crypto | |
parent | 6807b84eacc89aee6eed2730e7dd3ce7171cc834 (diff) |
Replace malloc+strcpy with strdup
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4371)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/dso/dso_dl.c | 6 | ||||
-rw-r--r-- | crypto/dso/dso_dlfcn.c | 6 | ||||
-rw-r--r-- | crypto/dso/dso_win32.c | 6 |
3 files changed, 6 insertions, 12 deletions
diff --git a/crypto/dso/dso_dl.c b/crypto/dso/dso_dl.c index af968e3ead..d80bf562c7 100644 --- a/crypto/dso/dso_dl.c +++ b/crypto/dso/dso_dl.c @@ -156,23 +156,21 @@ static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2) * if the second file specification is missing. */ if (!filespec2 || filespec1[0] == '/') { - merged = OPENSSL_malloc(strlen(filespec1) + 1); + merged = OPENSSL_strdup(filespec1); if (merged == NULL) { DSOerr(DSO_F_DL_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_malloc(strlen(filespec2) + 1); + merged = OPENSSL_strdup(filespec2); if (merged == NULL) { DSOerr(DSO_F_DL_MERGER, ERR_R_MALLOC_FAILURE); return (NULL); } - strcpy(merged, filespec2); } else /* * This part isn't as trivial as it looks. It assumes that the diff --git a/crypto/dso/dso_dlfcn.c b/crypto/dso/dso_dlfcn.c index e2aa76eb65..a4b0cdd95b 100644 --- a/crypto/dso/dso_dlfcn.c +++ b/crypto/dso/dso_dlfcn.c @@ -196,23 +196,21 @@ static char *dlfcn_merger(DSO *dso, const char *filespec1, * if the second file specification is missing. */ if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) { - merged = OPENSSL_malloc(strlen(filespec1) + 1); + merged = OPENSSL_strdup(filespec1); 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_malloc(strlen(filespec2) + 1); + merged = OPENSSL_strdup(filespec2); 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 diff --git a/crypto/dso/dso_win32.c b/crypto/dso/dso_win32.c index 635974be70..5f50774bb8 100644 --- a/crypto/dso/dso_win32.c +++ b/crypto/dso/dso_win32.c @@ -398,19 +398,17 @@ static char *win32_merger(DSO *dso, const char *filespec1, return (NULL); } if (!filespec2) { - merged = OPENSSL_malloc(strlen(filespec1) + 1); + merged = OPENSSL_strdup(filespec1); if (merged == NULL) { DSOerr(DSO_F_WIN32_MERGER, ERR_R_MALLOC_FAILURE); return (NULL); } - strcpy(merged, filespec1); } else if (!filespec1) { - merged = OPENSSL_malloc(strlen(filespec2) + 1); + merged = OPENSSL_strdup(filespec2); if (merged == NULL) { DSOerr(DSO_F_WIN32_MERGER, ERR_R_MALLOC_FAILURE); return (NULL); } - strcpy(merged, filespec2); } else { filespec1_split = win32_splitter(dso, filespec1, 0); if (!filespec1_split) { |