mirror of
https://github.com/openssl/openssl.git
synced 2024-11-27 05:21:51 +08:00
Replace malloc+strcpy with strdup
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4371)
This commit is contained in:
parent
6807b84eac
commit
297002a332
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user