summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormiod <>2014-10-07 04:59:25 +0000
committermiod <>2014-10-07 04:59:25 +0000
commitc2cca954d749dce6972a5557d913706593a02240 (patch)
treeb6dac04804cef0e640c5a0a7e47bae1050e632c4 /src
parent93f7d0ffdf10b7d5b4a44864db24f6cbfac925c1 (diff)
downloadopenbsd-c2cca954d749dce6972a5557d913706593a02240.tar.gz
openbsd-c2cca954d749dce6972a5557d913706593a02240.tar.bz2
openbsd-c2cca954d749dce6972a5557d913706593a02240.zip
Use strdup() instead of malloc() + memcpy().
ok doug@ jsing@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/objects/obj_lib.c11
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_lib.c11
2 files changed, 6 insertions, 16 deletions
diff --git a/src/lib/libcrypto/objects/obj_lib.c b/src/lib/libcrypto/objects/obj_lib.c
index 6dc515e628..247bafbe01 100644
--- a/src/lib/libcrypto/objects/obj_lib.c
+++ b/src/lib/libcrypto/objects/obj_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: obj_lib.c,v 1.12 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: obj_lib.c,v 1.13 2014/10/07 04:59:25 miod Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -68,7 +68,6 @@ ASN1_OBJECT *
68OBJ_dup(const ASN1_OBJECT *o) 68OBJ_dup(const ASN1_OBJECT *o)
69{ 69{
70 ASN1_OBJECT *r; 70 ASN1_OBJECT *r;
71 int i;
72 char *ln = NULL, *sn = NULL; 71 char *ln = NULL, *sn = NULL;
73 unsigned char *data = NULL; 72 unsigned char *data = NULL;
74 73
@@ -94,20 +93,16 @@ OBJ_dup(const ASN1_OBJECT *o)
94 r->nid = o->nid; 93 r->nid = o->nid;
95 r->ln = r->sn = NULL; 94 r->ln = r->sn = NULL;
96 if (o->ln != NULL) { 95 if (o->ln != NULL) {
97 i = strlen(o->ln) + 1; 96 ln = strdup(o->ln);
98 ln = malloc(i);
99 if (ln == NULL) 97 if (ln == NULL)
100 goto err; 98 goto err;
101 memcpy(ln, o->ln, i);
102 r->ln = ln; 99 r->ln = ln;
103 } 100 }
104 101
105 if (o->sn != NULL) { 102 if (o->sn != NULL) {
106 i = strlen(o->sn) + 1; 103 sn = strdup(o->sn);
107 sn = malloc(i);
108 if (sn == NULL) 104 if (sn == NULL)
109 goto err; 105 goto err;
110 memcpy(sn, o->sn, i);
111 r->sn = sn; 106 r->sn = sn;
112 } 107 }
113 r->flags = o->flags | (ASN1_OBJECT_FLAG_DYNAMIC | 108 r->flags = o->flags | (ASN1_OBJECT_FLAG_DYNAMIC |
diff --git a/src/lib/libssl/src/crypto/objects/obj_lib.c b/src/lib/libssl/src/crypto/objects/obj_lib.c
index 6dc515e628..247bafbe01 100644
--- a/src/lib/libssl/src/crypto/objects/obj_lib.c
+++ b/src/lib/libssl/src/crypto/objects/obj_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: obj_lib.c,v 1.12 2014/07/11 08:44:49 jsing Exp $ */ 1/* $OpenBSD: obj_lib.c,v 1.13 2014/10/07 04:59:25 miod Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -68,7 +68,6 @@ ASN1_OBJECT *
68OBJ_dup(const ASN1_OBJECT *o) 68OBJ_dup(const ASN1_OBJECT *o)
69{ 69{
70 ASN1_OBJECT *r; 70 ASN1_OBJECT *r;
71 int i;
72 char *ln = NULL, *sn = NULL; 71 char *ln = NULL, *sn = NULL;
73 unsigned char *data = NULL; 72 unsigned char *data = NULL;
74 73
@@ -94,20 +93,16 @@ OBJ_dup(const ASN1_OBJECT *o)
94 r->nid = o->nid; 93 r->nid = o->nid;
95 r->ln = r->sn = NULL; 94 r->ln = r->sn = NULL;
96 if (o->ln != NULL) { 95 if (o->ln != NULL) {
97 i = strlen(o->ln) + 1; 96 ln = strdup(o->ln);
98 ln = malloc(i);
99 if (ln == NULL) 97 if (ln == NULL)
100 goto err; 98 goto err;
101 memcpy(ln, o->ln, i);
102 r->ln = ln; 99 r->ln = ln;
103 } 100 }
104 101
105 if (o->sn != NULL) { 102 if (o->sn != NULL) {
106 i = strlen(o->sn) + 1; 103 sn = strdup(o->sn);
107 sn = malloc(i);
108 if (sn == NULL) 104 if (sn == NULL)
109 goto err; 105 goto err;
110 memcpy(sn, o->sn, i);
111 r->sn = sn; 106 r->sn = sn;
112 } 107 }
113 r->flags = o->flags | (ASN1_OBJECT_FLAG_DYNAMIC | 108 r->flags = o->flags | (ASN1_OBJECT_FLAG_DYNAMIC |