diff options
author | deraadt <> | 2014-05-30 06:22:57 +0000 |
---|---|---|
committer | deraadt <> | 2014-05-30 06:22:57 +0000 |
commit | abd9b10898e82011a65d8e8fca56bf56532edd69 (patch) | |
tree | 1ff700d79cee9e764329e5c50d7eb8d5109789cc /src/lib/libcrypto/asn1 | |
parent | 2ff11427d41a52cb126e9892413db066f8ae166a (diff) | |
download | openbsd-abd9b10898e82011a65d8e8fca56bf56532edd69.tar.gz openbsd-abd9b10898e82011a65d8e8fca56bf56532edd69.tar.bz2 openbsd-abd9b10898e82011a65d8e8fca56bf56532edd69.zip |
more: no need for null check before free
ok tedu guenther
Diffstat (limited to 'src/lib/libcrypto/asn1')
-rw-r--r-- | src/lib/libcrypto/asn1/a_bitstr.c | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/a_bytes.c | 15 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/a_enum.c | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/a_gentm.c | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/a_int.c | 9 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/a_object.c | 12 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/a_sign.c | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/a_utctm.c | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/asn1_gen.c | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/t_x509.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/x_info.c | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/x_x509.c | 6 |
12 files changed, 23 insertions, 46 deletions
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c index f3cce8b536..058a3ccc5f 100644 --- a/src/lib/libcrypto/asn1/a_bitstr.c +++ b/src/lib/libcrypto/asn1/a_bitstr.c | |||
@@ -165,8 +165,7 @@ c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, const unsigned char **pp, long len) | |||
165 | s = NULL; | 165 | s = NULL; |
166 | 166 | ||
167 | ret->length = (int)len; | 167 | ret->length = (int)len; |
168 | if (ret->data != NULL) | 168 | free(ret->data); |
169 | free(ret->data); | ||
170 | ret->data = s; | 169 | ret->data = s; |
171 | ret->type = V_ASN1_BIT_STRING; | 170 | ret->type = V_ASN1_BIT_STRING; |
172 | if (a != NULL) | 171 | if (a != NULL) |
diff --git a/src/lib/libcrypto/asn1/a_bytes.c b/src/lib/libcrypto/asn1/a_bytes.c index 6cc774e782..0d26e46681 100644 --- a/src/lib/libcrypto/asn1/a_bytes.c +++ b/src/lib/libcrypto/asn1/a_bytes.c | |||
@@ -110,8 +110,7 @@ d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp, | |||
110 | } else | 110 | } else |
111 | s = NULL; | 111 | s = NULL; |
112 | 112 | ||
113 | if (ret->data != NULL) | 113 | free(ret->data); |
114 | free(ret->data); | ||
115 | ret->length = (int)len; | 114 | ret->length = (int)len; |
116 | ret->data = s; | 115 | ret->data = s; |
117 | ret->type = tag; | 116 | ret->type = tag; |
@@ -203,8 +202,7 @@ d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, | |||
203 | } else { | 202 | } else { |
204 | if (len != 0) { | 203 | if (len != 0) { |
205 | if ((ret->length < len) || (ret->data == NULL)) { | 204 | if ((ret->length < len) || (ret->data == NULL)) { |
206 | if (ret->data != NULL) | 205 | free(ret->data); |
207 | free(ret->data); | ||
208 | ret->data = NULL; | 206 | ret->data = NULL; |
209 | s = malloc(len + 1); | 207 | s = malloc(len + 1); |
210 | if (s == NULL) { | 208 | if (s == NULL) { |
@@ -218,8 +216,7 @@ d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, | |||
218 | p += len; | 216 | p += len; |
219 | } else { | 217 | } else { |
220 | s = NULL; | 218 | s = NULL; |
221 | if (ret->data != NULL) | 219 | free(ret->data); |
222 | free(ret->data); | ||
223 | } | 220 | } |
224 | 221 | ||
225 | ret->length = (int)len; | 222 | ret->length = (int)len; |
@@ -293,8 +290,7 @@ asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c) | |||
293 | goto err; | 290 | goto err; |
294 | 291 | ||
295 | a->length = num; | 292 | a->length = num; |
296 | if (a->data != NULL) | 293 | free(a->data); |
297 | free(a->data); | ||
298 | a->data = (unsigned char *)b.data; | 294 | a->data = (unsigned char *)b.data; |
299 | if (os != NULL) | 295 | if (os != NULL) |
300 | ASN1_STRING_free(os); | 296 | ASN1_STRING_free(os); |
@@ -304,7 +300,6 @@ err: | |||
304 | ASN1err(ASN1_F_ASN1_COLLATE_PRIMITIVE, c->error); | 300 | ASN1err(ASN1_F_ASN1_COLLATE_PRIMITIVE, c->error); |
305 | if (os != NULL) | 301 | if (os != NULL) |
306 | ASN1_STRING_free(os); | 302 | ASN1_STRING_free(os); |
307 | if (b.data != NULL) | 303 | free(b.data); |
308 | free(b.data); | ||
309 | return (0); | 304 | return (0); |
310 | } | 305 | } |
diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c index aa28c7c8d7..b514288782 100644 --- a/src/lib/libcrypto/asn1/a_enum.c +++ b/src/lib/libcrypto/asn1/a_enum.c | |||
@@ -76,8 +76,7 @@ ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) | |||
76 | 76 | ||
77 | a->type = V_ASN1_ENUMERATED; | 77 | a->type = V_ASN1_ENUMERATED; |
78 | if (a->length < (int)(sizeof(long) + 1)) { | 78 | if (a->length < (int)(sizeof(long) + 1)) { |
79 | if (a->data != NULL) | 79 | free(a->data); |
80 | free(a->data); | ||
81 | a->data = calloc(1, sizeof(long) + 1); | 80 | a->data = calloc(1, sizeof(long) + 1); |
82 | } | 81 | } |
83 | if (a->data == NULL) { | 82 | if (a->data == NULL) { |
diff --git a/src/lib/libcrypto/asn1/a_gentm.c b/src/lib/libcrypto/asn1/a_gentm.c index 7f8bc2fef7..e9881943a1 100644 --- a/src/lib/libcrypto/asn1/a_gentm.c +++ b/src/lib/libcrypto/asn1/a_gentm.c | |||
@@ -234,8 +234,7 @@ ASN1_GENERALIZEDTIME_adj_internal(ASN1_GENERALIZEDTIME *s, time_t t, | |||
234 | ERR_R_MALLOC_FAILURE); | 234 | ERR_R_MALLOC_FAILURE); |
235 | return (NULL); | 235 | return (NULL); |
236 | } | 236 | } |
237 | if (s->data != NULL) | 237 | free(s->data); |
238 | free(s->data); | ||
239 | s->data = (unsigned char *)p; | 238 | s->data = (unsigned char *)p; |
240 | } | 239 | } |
241 | 240 | ||
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c index 0559cce384..881f08a766 100644 --- a/src/lib/libcrypto/asn1/a_int.c +++ b/src/lib/libcrypto/asn1/a_int.c | |||
@@ -256,8 +256,7 @@ c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, long len) | |||
256 | memcpy(s, p, (int)len); | 256 | memcpy(s, p, (int)len); |
257 | } | 257 | } |
258 | 258 | ||
259 | if (ret->data != NULL) | 259 | free(ret->data); |
260 | free(ret->data); | ||
261 | ret->data = s; | 260 | ret->data = s; |
262 | ret->length = (int)len; | 261 | ret->length = (int)len; |
263 | if (a != NULL) | 262 | if (a != NULL) |
@@ -324,8 +323,7 @@ d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, long length) | |||
324 | p += len; | 323 | p += len; |
325 | } | 324 | } |
326 | 325 | ||
327 | if (ret->data != NULL) | 326 | free(ret->data); |
328 | free(ret->data); | ||
329 | ret->data = s; | 327 | ret->data = s; |
330 | ret->length = (int)len; | 328 | ret->length = (int)len; |
331 | if (a != NULL) | 329 | if (a != NULL) |
@@ -350,8 +348,7 @@ ASN1_INTEGER_set(ASN1_INTEGER *a, long v) | |||
350 | 348 | ||
351 | a->type = V_ASN1_INTEGER; | 349 | a->type = V_ASN1_INTEGER; |
352 | if (a->length < (int)(sizeof(long) + 1)) { | 350 | if (a->length < (int)(sizeof(long) + 1)) { |
353 | if (a->data != NULL) | 351 | free(a->data); |
354 | free(a->data); | ||
355 | a->data = calloc(1, sizeof(long) + 1); | 352 | a->data = calloc(1, sizeof(long) + 1); |
356 | } | 353 | } |
357 | if (a->data == NULL) { | 354 | if (a->data == NULL) { |
diff --git a/src/lib/libcrypto/asn1/a_object.c b/src/lib/libcrypto/asn1/a_object.c index b3a7e672ee..34221e0e98 100644 --- a/src/lib/libcrypto/asn1/a_object.c +++ b/src/lib/libcrypto/asn1/a_object.c | |||
@@ -310,8 +310,7 @@ c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, long len) | |||
310 | /* once detached we can change it */ | 310 | /* once detached we can change it */ |
311 | if ((data == NULL) || (ret->length < len)) { | 311 | if ((data == NULL) || (ret->length < len)) { |
312 | ret->length = 0; | 312 | ret->length = 0; |
313 | if (data != NULL) | 313 | free(data); |
314 | free(data); | ||
315 | data = malloc(len ? (int)len : 1); | 314 | data = malloc(len ? (int)len : 1); |
316 | if (data == NULL) { | 315 | if (data == NULL) { |
317 | i = ERR_R_MALLOC_FAILURE; | 316 | i = ERR_R_MALLOC_FAILURE; |
@@ -365,15 +364,12 @@ ASN1_OBJECT_free(ASN1_OBJECT *a) | |||
365 | if (a == NULL) | 364 | if (a == NULL) |
366 | return; | 365 | return; |
367 | if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) { | 366 | if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) { |
368 | if (a->sn != NULL) | 367 | free((void *)a->sn); |
369 | free((void *)a->sn); | 368 | free((void *)a->ln); |
370 | if (a->ln != NULL) | ||
371 | free((void *)a->ln); | ||
372 | a->sn = a->ln = NULL; | 369 | a->sn = a->ln = NULL; |
373 | } | 370 | } |
374 | if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA) { | 371 | if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA) { |
375 | if (a->data != NULL) | 372 | free((void *)a->data); |
376 | free((void *)a->data); | ||
377 | a->data = NULL; | 373 | a->data = NULL; |
378 | a->length = 0; | 374 | a->length = 0; |
379 | } | 375 | } |
diff --git a/src/lib/libcrypto/asn1/a_sign.c b/src/lib/libcrypto/asn1/a_sign.c index 40c6809669..2705a0402e 100644 --- a/src/lib/libcrypto/asn1/a_sign.c +++ b/src/lib/libcrypto/asn1/a_sign.c | |||
@@ -218,8 +218,7 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, | |||
218 | ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB); | 218 | ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB); |
219 | goto err; | 219 | goto err; |
220 | } | 220 | } |
221 | if (signature->data != NULL) | 221 | free(signature->data); |
222 | free(signature->data); | ||
223 | signature->data = buf_out; | 222 | signature->data = buf_out; |
224 | buf_out = NULL; | 223 | buf_out = NULL; |
225 | signature->length = outl; | 224 | signature->length = outl; |
diff --git a/src/lib/libcrypto/asn1/a_utctm.c b/src/lib/libcrypto/asn1/a_utctm.c index 35f2b7fd66..b8e5b7afc1 100644 --- a/src/lib/libcrypto/asn1/a_utctm.c +++ b/src/lib/libcrypto/asn1/a_utctm.c | |||
@@ -177,8 +177,7 @@ ASN1_UTCTIME_adj_internal(ASN1_UTCTIME *s, time_t t, int offset_day, | |||
177 | ASN1err(ASN1_F_ASN1_UTCTIME_ADJ, ERR_R_MALLOC_FAILURE); | 177 | ASN1err(ASN1_F_ASN1_UTCTIME_ADJ, ERR_R_MALLOC_FAILURE); |
178 | return (NULL); | 178 | return (NULL); |
179 | } | 179 | } |
180 | if (s->data != NULL) | 180 | free(s->data); |
181 | free(s->data); | ||
182 | s->data = (unsigned char *)p; | 181 | s->data = (unsigned char *)p; |
183 | } | 182 | } |
184 | 183 | ||
diff --git a/src/lib/libcrypto/asn1/asn1_gen.c b/src/lib/libcrypto/asn1/asn1_gen.c index 7abbac6059..8ab8944d64 100644 --- a/src/lib/libcrypto/asn1/asn1_gen.c +++ b/src/lib/libcrypto/asn1/asn1_gen.c | |||
@@ -474,8 +474,7 @@ asn1_multi(int utype, const char *section, X509V3_CTX *cnf) | |||
474 | der = NULL; | 474 | der = NULL; |
475 | 475 | ||
476 | bad: | 476 | bad: |
477 | if (der) | 477 | free(der); |
478 | free(der); | ||
479 | if (sk) | 478 | if (sk) |
480 | sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free); | 479 | sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free); |
481 | if (sect) | 480 | if (sect) |
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c index efba93adeb..f1c045e0e6 100644 --- a/src/lib/libcrypto/asn1/t_x509.c +++ b/src/lib/libcrypto/asn1/t_x509.c | |||
@@ -245,8 +245,7 @@ X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) | |||
245 | ret = 1; | 245 | ret = 1; |
246 | 246 | ||
247 | err: | 247 | err: |
248 | if (m != NULL) | 248 | free(m); |
249 | free(m); | ||
250 | return (ret); | 249 | return (ret); |
251 | } | 250 | } |
252 | 251 | ||
@@ -294,8 +293,7 @@ int X509_ocspid_print (BIO *bp, X509 *x) | |||
294 | return (1); | 293 | return (1); |
295 | 294 | ||
296 | err: | 295 | err: |
297 | if (der != NULL) | 296 | free(der); |
298 | free(der); | ||
299 | return (0); | 297 | return (0); |
300 | } | 298 | } |
301 | 299 | ||
diff --git a/src/lib/libcrypto/asn1/x_info.c b/src/lib/libcrypto/asn1/x_info.c index 2d1bf0d22d..b17d7ace11 100644 --- a/src/lib/libcrypto/asn1/x_info.c +++ b/src/lib/libcrypto/asn1/x_info.c | |||
@@ -102,8 +102,7 @@ X509_INFO_free(X509_INFO *x) | |||
102 | X509_CRL_free(x->crl); | 102 | X509_CRL_free(x->crl); |
103 | if (x->x_pkey != NULL) | 103 | if (x->x_pkey != NULL) |
104 | X509_PKEY_free(x->x_pkey); | 104 | X509_PKEY_free(x->x_pkey); |
105 | if (x->enc_data != NULL) | 105 | free(x->enc_data); |
106 | free(x->enc_data); | ||
107 | free(x); | 106 | free(x); |
108 | } | 107 | } |
109 | 108 | ||
diff --git a/src/lib/libcrypto/asn1/x_x509.c b/src/lib/libcrypto/asn1/x_x509.c index e93d97d2c4..7053bb87eb 100644 --- a/src/lib/libcrypto/asn1/x_x509.c +++ b/src/lib/libcrypto/asn1/x_x509.c | |||
@@ -105,8 +105,7 @@ x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
105 | break; | 105 | break; |
106 | 106 | ||
107 | case ASN1_OP_D2I_POST: | 107 | case ASN1_OP_D2I_POST: |
108 | if (ret->name != NULL) | 108 | free(ret->name); |
109 | free(ret->name); | ||
110 | ret->name = X509_NAME_oneline(ret->cert_info->subject, NULL, 0); | 109 | ret->name = X509_NAME_oneline(ret->cert_info->subject, NULL, 0); |
111 | break; | 110 | break; |
112 | 111 | ||
@@ -123,8 +122,7 @@ x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | |||
123 | sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free); | 122 | sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free); |
124 | ASIdentifiers_free(ret->rfc3779_asid); | 123 | ASIdentifiers_free(ret->rfc3779_asid); |
125 | #endif | 124 | #endif |
126 | if (ret->name != NULL) | 125 | free(ret->name); |
127 | free(ret->name); | ||
128 | ret->name = NULL; | 126 | ret->name = NULL; |
129 | break; | 127 | break; |
130 | } | 128 | } |