summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2014-10-07 04:59:25 +0000
committermiod <miod@openbsd.org>2014-10-07 04:59:25 +0000
commit6cc6ee524bf0e3de2624c730b0168852d61e48d7 (patch)
tree60c7de09c85249f4a9789127f33a754d34adc014
parentEC_KEY_set_group() does an EC_GROUP_dup() of its argument, so we don't (diff)
downloadwireguard-openbsd-6cc6ee524bf0e3de2624c730b0168852d61e48d7.tar.xz
wireguard-openbsd-6cc6ee524bf0e3de2624c730b0168852d61e48d7.zip
Use strdup() instead of malloc() + memcpy().
ok doug@ jsing@
-rw-r--r--lib/libcrypto/objects/obj_lib.c11
-rw-r--r--lib/libssl/src/crypto/objects/obj_lib.c11
2 files changed, 6 insertions, 16 deletions
diff --git a/lib/libcrypto/objects/obj_lib.c b/lib/libcrypto/objects/obj_lib.c
index 6dc515e6287..247bafbe019 100644
--- a/lib/libcrypto/objects/obj_lib.c
+++ b/lib/libcrypto/objects/obj_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: obj_lib.c,v 1.12 2014/07/11 08:44:49 jsing Exp $ */
+/* $OpenBSD: obj_lib.c,v 1.13 2014/10/07 04:59:25 miod Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -68,7 +68,6 @@ ASN1_OBJECT *
OBJ_dup(const ASN1_OBJECT *o)
{
ASN1_OBJECT *r;
- int i;
char *ln = NULL, *sn = NULL;
unsigned char *data = NULL;
@@ -94,20 +93,16 @@ OBJ_dup(const ASN1_OBJECT *o)
r->nid = o->nid;
r->ln = r->sn = NULL;
if (o->ln != NULL) {
- i = strlen(o->ln) + 1;
- ln = malloc(i);
+ ln = strdup(o->ln);
if (ln == NULL)
goto err;
- memcpy(ln, o->ln, i);
r->ln = ln;
}
if (o->sn != NULL) {
- i = strlen(o->sn) + 1;
- sn = malloc(i);
+ sn = strdup(o->sn);
if (sn == NULL)
goto err;
- memcpy(sn, o->sn, i);
r->sn = sn;
}
r->flags = o->flags | (ASN1_OBJECT_FLAG_DYNAMIC |
diff --git a/lib/libssl/src/crypto/objects/obj_lib.c b/lib/libssl/src/crypto/objects/obj_lib.c
index 6dc515e6287..247bafbe019 100644
--- a/lib/libssl/src/crypto/objects/obj_lib.c
+++ b/lib/libssl/src/crypto/objects/obj_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: obj_lib.c,v 1.12 2014/07/11 08:44:49 jsing Exp $ */
+/* $OpenBSD: obj_lib.c,v 1.13 2014/10/07 04:59:25 miod Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -68,7 +68,6 @@ ASN1_OBJECT *
OBJ_dup(const ASN1_OBJECT *o)
{
ASN1_OBJECT *r;
- int i;
char *ln = NULL, *sn = NULL;
unsigned char *data = NULL;
@@ -94,20 +93,16 @@ OBJ_dup(const ASN1_OBJECT *o)
r->nid = o->nid;
r->ln = r->sn = NULL;
if (o->ln != NULL) {
- i = strlen(o->ln) + 1;
- ln = malloc(i);
+ ln = strdup(o->ln);
if (ln == NULL)
goto err;
- memcpy(ln, o->ln, i);
r->ln = ln;
}
if (o->sn != NULL) {
- i = strlen(o->sn) + 1;
- sn = malloc(i);
+ sn = strdup(o->sn);
if (sn == NULL)
goto err;
- memcpy(sn, o->sn, i);
r->sn = sn;
}
r->flags = o->flags | (ASN1_OBJECT_FLAG_DYNAMIC |