From 40e1b308306633da3204f243350176f8b3d377af Mon Sep 17 00:00:00 2001
From: tedu <>
Date: Wed, 23 Apr 2014 21:54:30 +0000
Subject: replace a bunch of hand duped strings with strdup

---
 src/lib/libcrypto/dso/dso_dlfcn.c         | 8 ++------
 src/lib/libcrypto/dso/dso_lib.c           | 6 ++----
 src/lib/libssl/src/crypto/dso/dso_dlfcn.c | 8 ++------
 src/lib/libssl/src/crypto/dso/dso_lib.c   | 6 ++----
 4 files changed, 8 insertions(+), 20 deletions(-)

(limited to 'src/lib')

diff --git a/src/lib/libcrypto/dso/dso_dlfcn.c b/src/lib/libcrypto/dso/dso_dlfcn.c
index 62b826ea43..9731df136d 100644
--- a/src/lib/libcrypto/dso/dso_dlfcn.c
+++ b/src/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/src/lib/libcrypto/dso/dso_lib.c b/src/lib/libcrypto/dso/dso_lib.c
index ae10104560..882b9c2fcb 100644
--- a/src/lib/libcrypto/dso/dso_lib.c
+++ b/src/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);
 }
diff --git a/src/lib/libssl/src/crypto/dso/dso_dlfcn.c b/src/lib/libssl/src/crypto/dso/dso_dlfcn.c
index 62b826ea43..9731df136d 100644
--- a/src/lib/libssl/src/crypto/dso/dso_dlfcn.c
+++ b/src/lib/libssl/src/crypto/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/src/lib/libssl/src/crypto/dso/dso_lib.c b/src/lib/libssl/src/crypto/dso/dso_lib.c
index ae10104560..882b9c2fcb 100644
--- a/src/lib/libssl/src/crypto/dso/dso_lib.c
+++ b/src/lib/libssl/src/crypto/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);
 }
-- 
cgit v1.2.3-55-g6feb