* 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
* 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
char *CRYPTO_strdup(const char *str, const char* file, int line)
{
char *ret;
+ size_t size;
if (str == NULL)
return NULL;
- ret = CRYPTO_malloc(strlen(str) + 1, file, line);
+ size = strlen(str) + 1;
+ ret = CRYPTO_malloc(size, file, line);
if (ret != NULL)
- strcpy(ret, str);
+ memcpy(ret, str, size);
return ret;
}
*p = '\0';
return buf;
}
- strcpy(p, c->name);
+ memcpy(p, c->name, n + 1);
p += n;
*(p++) = ':';
len -= n + 1;