diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2014-04-23 21:54:31 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2014-04-23 21:54:31 +0000 |
commit | 3be95bf40b66290ae614232703b647e563e5bf9a (patch) | |
tree | f3fde1bde9d9c00acc1e6d4ab335d3785d6b9fa1 /lib/libcrypto | |
parent | 32414bdab173096ed74e41d5d6bca47ce80629c4 (diff) |
replace a bunch of hand duped strings with strdup
Diffstat (limited to 'lib/libcrypto')
-rw-r--r-- | lib/libcrypto/dso/dso_dlfcn.c | 8 | ||||
-rw-r--r-- | lib/libcrypto/dso/dso_lib.c | 6 |
2 files changed, 4 insertions, 10 deletions
diff --git a/lib/libcrypto/dso/dso_dlfcn.c b/lib/libcrypto/dso/dso_dlfcn.c index 62b826ea430..9731df136d1 100644 --- a/lib/libcrypto/dso/dso_dlfcn.c +++ b/lib/libcrypto/dso/dso_dlfcn.c @@ -255,23 +255,19 @@ dlfcn_merger(DSO *dso, const char *filespec1, const char *filespec2) /* If the first file specification is a rooted path, it rules. same goes if the second file specification is missing. */ if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) { - len = strlen(filespec1) + 1; - merged = malloc(len); + merged = strdup(filespec1); if (!merged) { DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); return (NULL); } - strlcpy(merged, filespec1, len); } /* If the first file specification is missing, the second one rules. */ else if (!filespec1) { - len = strlen(filespec2) + 1; - merged = malloc(strlen(filespec2) + 1); + merged = strdup(filespec2); if (!merged) { DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); return (NULL); } - strlcpy(merged, filespec2, len); } else /* This part isn't as trivial as it looks. It assumes that the second file specification really is a directory, and diff --git a/lib/libcrypto/dso/dso_lib.c b/lib/libcrypto/dso/dso_lib.c index ae10104560e..882b9c2fcbf 100644 --- a/lib/libcrypto/dso/dso_lib.c +++ b/lib/libcrypto/dso/dso_lib.c @@ -356,12 +356,11 @@ DSO_set_filename(DSO *dso, const char *filename) return (0); } /* We'll duplicate filename */ - copied = malloc(strlen(filename) + 1); + copied = strdup(filename); if (copied == NULL) { DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE); return (0); } - strlcpy(copied, filename, strlen(filename) + 1); if (dso->filename) free(dso->filename); dso->filename = copied; @@ -409,13 +408,12 @@ DSO_convert_filename(DSO *dso, const char *filename) result = dso->meth->dso_name_converter(dso, filename); } if (result == NULL) { - result = malloc(strlen(filename) + 1); + result = strdup(filename); if (result == NULL) { DSOerr(DSO_F_DSO_CONVERT_FILENAME, ERR_R_MALLOC_FAILURE); return (NULL); } - strlcpy(result, filename, strlen(filename) + 1); } return (result); } |