提交 edae9834 编写于 作者: D Dmitry-Me 提交者: Rich Salz

GH762: Reuse strdup()

Signed-off-by: NRich Salz <rsalz@openssl.org>
Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 1c03c81f
......@@ -341,12 +341,11 @@ int DSO_set_filename(DSO *dso, const char *filename)
return (0);
}
/* We'll duplicate filename */
copied = OPENSSL_malloc(strlen(filename) + 1);
copied = OPENSSL_strdup(filename);
if (copied == NULL) {
DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE);
return (0);
}
OPENSSL_strlcpy(copied, filename, strlen(filename) + 1);
OPENSSL_free(dso->filename);
dso->filename = copied;
return (1);
......@@ -390,12 +389,11 @@ char *DSO_convert_filename(DSO *dso, const char *filename)
result = dso->meth->dso_name_converter(dso, filename);
}
if (result == NULL) {
result = OPENSSL_malloc(strlen(filename) + 1);
result = OPENSSL_strdup(filename);
if (result == NULL) {
DSOerr(DSO_F_DSO_CONVERT_FILENAME, ERR_R_MALLOC_FAILURE);
return (NULL);
}
OPENSSL_strlcpy(result, filename, strlen(filename) + 1);
}
return (result);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册