diff options
| author | tedu <> | 2014-04-23 21:54:30 +0000 |
|---|---|---|
| committer | tedu <> | 2014-04-23 21:54:30 +0000 |
| commit | 40e1b308306633da3204f243350176f8b3d377af (patch) | |
| tree | 51472f3b7b5c6b52c0e273040c476fc4aade2dd5 | |
| parent | 19826178d23fb598dbbfc0bf856cf8a6842827db (diff) | |
| download | openbsd-40e1b308306633da3204f243350176f8b3d377af.tar.gz openbsd-40e1b308306633da3204f243350176f8b3d377af.tar.bz2 openbsd-40e1b308306633da3204f243350176f8b3d377af.zip | |
replace a bunch of hand duped strings with strdup
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/dso/dso_dlfcn.c | 8 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_lib.c | 6 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/dso/dso_dlfcn.c | 8 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/dso/dso_lib.c | 6 |
4 files changed, 8 insertions, 20 deletions
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) | |||
| 255 | /* If the first file specification is a rooted path, it rules. | 255 | /* If the first file specification is a rooted path, it rules. |
| 256 | same goes if the second file specification is missing. */ | 256 | same goes if the second file specification is missing. */ |
| 257 | if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) { | 257 | if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) { |
| 258 | len = strlen(filespec1) + 1; | 258 | merged = strdup(filespec1); |
| 259 | merged = malloc(len); | ||
| 260 | if (!merged) { | 259 | if (!merged) { |
| 261 | DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); | 260 | DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); |
| 262 | return (NULL); | 261 | return (NULL); |
| 263 | } | 262 | } |
| 264 | strlcpy(merged, filespec1, len); | ||
| 265 | } | 263 | } |
| 266 | /* If the first file specification is missing, the second one rules. */ | 264 | /* If the first file specification is missing, the second one rules. */ |
| 267 | else if (!filespec1) { | 265 | else if (!filespec1) { |
| 268 | len = strlen(filespec2) + 1; | 266 | merged = strdup(filespec2); |
| 269 | merged = malloc(strlen(filespec2) + 1); | ||
| 270 | if (!merged) { | 267 | if (!merged) { |
| 271 | DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); | 268 | DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); |
| 272 | return (NULL); | 269 | return (NULL); |
| 273 | } | 270 | } |
| 274 | strlcpy(merged, filespec2, len); | ||
| 275 | } else | 271 | } else |
| 276 | /* This part isn't as trivial as it looks. It assumes that | 272 | /* This part isn't as trivial as it looks. It assumes that |
| 277 | the second file specification really is a directory, and | 273 | 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) | |||
| 356 | return (0); | 356 | return (0); |
| 357 | } | 357 | } |
| 358 | /* We'll duplicate filename */ | 358 | /* We'll duplicate filename */ |
| 359 | copied = malloc(strlen(filename) + 1); | 359 | copied = strdup(filename); |
| 360 | if (copied == NULL) { | 360 | if (copied == NULL) { |
| 361 | DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE); | 361 | DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE); |
| 362 | return (0); | 362 | return (0); |
| 363 | } | 363 | } |
| 364 | strlcpy(copied, filename, strlen(filename) + 1); | ||
| 365 | if (dso->filename) | 364 | if (dso->filename) |
| 366 | free(dso->filename); | 365 | free(dso->filename); |
| 367 | dso->filename = copied; | 366 | dso->filename = copied; |
| @@ -409,13 +408,12 @@ DSO_convert_filename(DSO *dso, const char *filename) | |||
| 409 | result = dso->meth->dso_name_converter(dso, filename); | 408 | result = dso->meth->dso_name_converter(dso, filename); |
| 410 | } | 409 | } |
| 411 | if (result == NULL) { | 410 | if (result == NULL) { |
| 412 | result = malloc(strlen(filename) + 1); | 411 | result = strdup(filename); |
| 413 | if (result == NULL) { | 412 | if (result == NULL) { |
| 414 | DSOerr(DSO_F_DSO_CONVERT_FILENAME, | 413 | DSOerr(DSO_F_DSO_CONVERT_FILENAME, |
| 415 | ERR_R_MALLOC_FAILURE); | 414 | ERR_R_MALLOC_FAILURE); |
| 416 | return (NULL); | 415 | return (NULL); |
| 417 | } | 416 | } |
| 418 | strlcpy(result, filename, strlen(filename) + 1); | ||
| 419 | } | 417 | } |
| 420 | return (result); | 418 | return (result); |
| 421 | } | 419 | } |
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) | |||
| 255 | /* If the first file specification is a rooted path, it rules. | 255 | /* If the first file specification is a rooted path, it rules. |
| 256 | same goes if the second file specification is missing. */ | 256 | same goes if the second file specification is missing. */ |
| 257 | if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) { | 257 | if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) { |
| 258 | len = strlen(filespec1) + 1; | 258 | merged = strdup(filespec1); |
| 259 | merged = malloc(len); | ||
| 260 | if (!merged) { | 259 | if (!merged) { |
| 261 | DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); | 260 | DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); |
| 262 | return (NULL); | 261 | return (NULL); |
| 263 | } | 262 | } |
| 264 | strlcpy(merged, filespec1, len); | ||
| 265 | } | 263 | } |
| 266 | /* If the first file specification is missing, the second one rules. */ | 264 | /* If the first file specification is missing, the second one rules. */ |
| 267 | else if (!filespec1) { | 265 | else if (!filespec1) { |
| 268 | len = strlen(filespec2) + 1; | 266 | merged = strdup(filespec2); |
| 269 | merged = malloc(strlen(filespec2) + 1); | ||
| 270 | if (!merged) { | 267 | if (!merged) { |
| 271 | DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); | 268 | DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); |
| 272 | return (NULL); | 269 | return (NULL); |
| 273 | } | 270 | } |
| 274 | strlcpy(merged, filespec2, len); | ||
| 275 | } else | 271 | } else |
| 276 | /* This part isn't as trivial as it looks. It assumes that | 272 | /* This part isn't as trivial as it looks. It assumes that |
| 277 | the second file specification really is a directory, and | 273 | 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) | |||
| 356 | return (0); | 356 | return (0); |
| 357 | } | 357 | } |
| 358 | /* We'll duplicate filename */ | 358 | /* We'll duplicate filename */ |
| 359 | copied = malloc(strlen(filename) + 1); | 359 | copied = strdup(filename); |
| 360 | if (copied == NULL) { | 360 | if (copied == NULL) { |
| 361 | DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE); | 361 | DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE); |
| 362 | return (0); | 362 | return (0); |
| 363 | } | 363 | } |
| 364 | strlcpy(copied, filename, strlen(filename) + 1); | ||
| 365 | if (dso->filename) | 364 | if (dso->filename) |
| 366 | free(dso->filename); | 365 | free(dso->filename); |
| 367 | dso->filename = copied; | 366 | dso->filename = copied; |
| @@ -409,13 +408,12 @@ DSO_convert_filename(DSO *dso, const char *filename) | |||
| 409 | result = dso->meth->dso_name_converter(dso, filename); | 408 | result = dso->meth->dso_name_converter(dso, filename); |
| 410 | } | 409 | } |
| 411 | if (result == NULL) { | 410 | if (result == NULL) { |
| 412 | result = malloc(strlen(filename) + 1); | 411 | result = strdup(filename); |
| 413 | if (result == NULL) { | 412 | if (result == NULL) { |
| 414 | DSOerr(DSO_F_DSO_CONVERT_FILENAME, | 413 | DSOerr(DSO_F_DSO_CONVERT_FILENAME, |
| 415 | ERR_R_MALLOC_FAILURE); | 414 | ERR_R_MALLOC_FAILURE); |
| 416 | return (NULL); | 415 | return (NULL); |
| 417 | } | 416 | } |
| 418 | strlcpy(result, filename, strlen(filename) + 1); | ||
| 419 | } | 417 | } |
| 420 | return (result); | 418 | return (result); |
| 421 | } | 419 | } |
