summaryrefslogtreecommitdiffstats
path: root/crypto/conf
diff options
context:
space:
mode:
authorraniervf <ranier_gyn@hotmail.com>2019-11-04 22:32:43 -0300
committerDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>2019-11-09 09:17:34 +0100
commit30bd3e51600b53ec0a2df2d952bf2624309f3952 (patch)
tree7231aeb754d0155e8a9772dbe13ecea1a79c10f2 /crypto/conf
parent53a5e9b561d0cc1c1c9a7ab9b0dbc91dd5e3623a (diff)
conf_def.c: Avoid calling strlen() in a loop
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/10361) (cherry picked from commit d1c1fb2d41a627293483d832aaffcb6eca9075f9)
Diffstat (limited to 'crypto/conf')
-rw-r--r--crypto/conf/conf_def.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
index 8e3f42a0ca..ca76fa3679 100644
--- a/crypto/conf/conf_def.c
+++ b/crypto/conf/conf_def.c
@@ -703,7 +703,9 @@ static BIO *process_include(char *include, OPENSSL_DIR_CTX **dirctx,
static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx)
{
const char *filename;
+ size_t pathlen;
+ pathlen = strlen(path);
while ((filename = OPENSSL_DIR_read(dirctx, path)) != NULL) {
size_t namelen;
@@ -716,7 +718,7 @@ static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx)
char *newpath;
BIO *bio;
- newlen = strlen(path) + namelen + 2;
+ newlen = pathlen + namelen + 2;
newpath = OPENSSL_zalloc(newlen);
if (newpath == NULL) {
CONFerr(CONF_F_GET_NEXT_FILE, ERR_R_MALLOC_FAILURE);
@@ -727,14 +729,11 @@ static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx)
* If the given path isn't clear VMS syntax,
* we treat it as on Unix.
*/
- {
- size_t pathlen = strlen(path);
-
- if (path[pathlen - 1] == ']' || path[pathlen - 1] == '>'
- || path[pathlen - 1] == ':') {
- /* Clear VMS directory syntax, just copy as is */
- OPENSSL_strlcpy(newpath, path, newlen);
- }
+ if (path[pathlen - 1] == ']'
+ || path[pathlen - 1] == '>'
+ || path[pathlen - 1] == ':') {
+ /* Clear VMS directory syntax, just copy as is */
+ OPENSSL_strlcpy(newpath, path, newlen);
}
#endif
if (newpath[0] == '\0') {