diff options
author | beck <> | 2017-01-29 17:49:23 +0000 |
---|---|---|
committer | beck <> | 2017-01-29 17:49:23 +0000 |
commit | 957b11334a7afb14537322f0e4795b2e368b3f59 (patch) | |
tree | 1a54abba678898ee5270ae4f3404a50ee9a92eea /src/lib/libcrypto/asn1/asn_mime.c | |
parent | df96e020e729c6c37a8c7fe311fdd1fe6a8718c5 (diff) | |
download | openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.tar.gz openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.tar.bz2 openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.zip |
Send the function codes from the error functions to the bit bucket,
as was done earlier in libssl. Thanks inoguchi@ for noticing
libssl had more reacharounds into this.
ok jsing@ inoguchi@
Diffstat (limited to 'src/lib/libcrypto/asn1/asn_mime.c')
-rw-r--r-- | src/lib/libcrypto/asn1/asn_mime.c | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/src/lib/libcrypto/asn1/asn_mime.c b/src/lib/libcrypto/asn1/asn_mime.c index 1d82f1a76f..6bad111775 100644 --- a/src/lib/libcrypto/asn1/asn_mime.c +++ b/src/lib/libcrypto/asn1/asn_mime.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: asn_mime.c,v 1.26 2015/02/22 15:19:56 jsing Exp $ */ | 1 | /* $OpenBSD: asn_mime.c,v 1.27 2017/01/29 17:49:22 beck Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project. | 3 | * project. |
4 | */ | 4 | */ |
@@ -122,8 +122,7 @@ i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, | |||
122 | BIO *bio, *tbio; | 122 | BIO *bio, *tbio; |
123 | bio = BIO_new_NDEF(out, val, it); | 123 | bio = BIO_new_NDEF(out, val, it); |
124 | if (!bio) { | 124 | if (!bio) { |
125 | ASN1err(ASN1_F_I2D_ASN1_BIO_STREAM, | 125 | ASN1error(ERR_R_MALLOC_FAILURE); |
126 | ERR_R_MALLOC_FAILURE); | ||
127 | return 0; | 126 | return 0; |
128 | } | 127 | } |
129 | SMIME_crlf_copy(in, bio, flags); | 128 | SMIME_crlf_copy(in, bio, flags); |
@@ -154,7 +153,7 @@ B64_write_ASN1(BIO *out, ASN1_VALUE *val, BIO *in, int flags, | |||
154 | 153 | ||
155 | b64 = BIO_new(BIO_f_base64()); | 154 | b64 = BIO_new(BIO_f_base64()); |
156 | if (!b64) { | 155 | if (!b64) { |
157 | ASN1err(ASN1_F_B64_WRITE_ASN1, ERR_R_MALLOC_FAILURE); | 156 | ASN1error(ERR_R_MALLOC_FAILURE); |
158 | return 0; | 157 | return 0; |
159 | } | 158 | } |
160 | /* prepend the b64 BIO so all data is base64 encoded. | 159 | /* prepend the b64 BIO so all data is base64 encoded. |
@@ -187,13 +186,13 @@ b64_read_asn1(BIO *bio, const ASN1_ITEM *it) | |||
187 | BIO *b64; | 186 | BIO *b64; |
188 | ASN1_VALUE *val; | 187 | ASN1_VALUE *val; |
189 | if (!(b64 = BIO_new(BIO_f_base64()))) { | 188 | if (!(b64 = BIO_new(BIO_f_base64()))) { |
190 | ASN1err(ASN1_F_B64_READ_ASN1, ERR_R_MALLOC_FAILURE); | 189 | ASN1error(ERR_R_MALLOC_FAILURE); |
191 | return 0; | 190 | return 0; |
192 | } | 191 | } |
193 | bio = BIO_push(b64, bio); | 192 | bio = BIO_push(b64, bio); |
194 | val = ASN1_item_d2i_bio(it, bio, NULL); | 193 | val = ASN1_item_d2i_bio(it, bio, NULL); |
195 | if (!val) | 194 | if (!val) |
196 | ASN1err(ASN1_F_B64_READ_ASN1, ASN1_R_DECODE_ERROR); | 195 | ASN1error(ASN1_R_DECODE_ERROR); |
197 | (void)BIO_flush(bio); | 196 | (void)BIO_flush(bio); |
198 | bio = BIO_pop(bio); | 197 | bio = BIO_pop(bio); |
199 | BIO_free(b64); | 198 | BIO_free(b64); |
@@ -388,8 +387,7 @@ asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags, | |||
388 | } | 387 | } |
389 | 388 | ||
390 | if (!aux || !aux->asn1_cb) { | 389 | if (!aux || !aux->asn1_cb) { |
391 | ASN1err(ASN1_F_ASN1_OUTPUT_DATA, | 390 | ASN1error(ASN1_R_STREAMING_NOT_SUPPORTED); |
392 | ASN1_R_STREAMING_NOT_SUPPORTED); | ||
393 | return 0; | 391 | return 0; |
394 | } | 392 | } |
395 | 393 | ||
@@ -440,13 +438,13 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) | |||
440 | *bcont = NULL; | 438 | *bcont = NULL; |
441 | 439 | ||
442 | if (!(headers = mime_parse_hdr(bio))) { | 440 | if (!(headers = mime_parse_hdr(bio))) { |
443 | ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_MIME_PARSE_ERROR); | 441 | ASN1error(ASN1_R_MIME_PARSE_ERROR); |
444 | return NULL; | 442 | return NULL; |
445 | } | 443 | } |
446 | 444 | ||
447 | if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { | 445 | if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { |
448 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); | 446 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
449 | ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_CONTENT_TYPE); | 447 | ASN1error(ASN1_R_NO_CONTENT_TYPE); |
450 | return NULL; | 448 | return NULL; |
451 | } | 449 | } |
452 | 450 | ||
@@ -457,15 +455,13 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) | |||
457 | prm = mime_param_find(hdr, "boundary"); | 455 | prm = mime_param_find(hdr, "boundary"); |
458 | if (!prm || !prm->param_value) { | 456 | if (!prm || !prm->param_value) { |
459 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); | 457 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
460 | ASN1err(ASN1_F_SMIME_READ_ASN1, | 458 | ASN1error(ASN1_R_NO_MULTIPART_BOUNDARY); |
461 | ASN1_R_NO_MULTIPART_BOUNDARY); | ||
462 | return NULL; | 459 | return NULL; |
463 | } | 460 | } |
464 | ret = multi_split(bio, prm->param_value, &parts); | 461 | ret = multi_split(bio, prm->param_value, &parts); |
465 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); | 462 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
466 | if (!ret || (sk_BIO_num(parts) != 2) ) { | 463 | if (!ret || (sk_BIO_num(parts) != 2) ) { |
467 | ASN1err(ASN1_F_SMIME_READ_ASN1, | 464 | ASN1error(ASN1_R_NO_MULTIPART_BODY_FAILURE); |
468 | ASN1_R_NO_MULTIPART_BODY_FAILURE); | ||
469 | sk_BIO_pop_free(parts, BIO_vfree); | 465 | sk_BIO_pop_free(parts, BIO_vfree); |
470 | return NULL; | 466 | return NULL; |
471 | } | 467 | } |
@@ -474,8 +470,7 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) | |||
474 | asnin = sk_BIO_value(parts, 1); | 470 | asnin = sk_BIO_value(parts, 1); |
475 | 471 | ||
476 | if (!(headers = mime_parse_hdr(asnin))) { | 472 | if (!(headers = mime_parse_hdr(asnin))) { |
477 | ASN1err(ASN1_F_SMIME_READ_ASN1, | 473 | ASN1error(ASN1_R_MIME_SIG_PARSE_ERROR); |
478 | ASN1_R_MIME_SIG_PARSE_ERROR); | ||
479 | sk_BIO_pop_free(parts, BIO_vfree); | 474 | sk_BIO_pop_free(parts, BIO_vfree); |
480 | return NULL; | 475 | return NULL; |
481 | } | 476 | } |
@@ -486,15 +481,13 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) | |||
486 | !hdr->value) { | 481 | !hdr->value) { |
487 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); | 482 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
488 | sk_BIO_pop_free(parts, BIO_vfree); | 483 | sk_BIO_pop_free(parts, BIO_vfree); |
489 | ASN1err(ASN1_F_SMIME_READ_ASN1, | 484 | ASN1error(ASN1_R_NO_SIG_CONTENT_TYPE); |
490 | ASN1_R_NO_SIG_CONTENT_TYPE); | ||
491 | return NULL; | 485 | return NULL; |
492 | } | 486 | } |
493 | 487 | ||
494 | if (strcmp(hdr->value, "application/x-pkcs7-signature") && | 488 | if (strcmp(hdr->value, "application/x-pkcs7-signature") && |
495 | strcmp(hdr->value, "application/pkcs7-signature")) { | 489 | strcmp(hdr->value, "application/pkcs7-signature")) { |
496 | ASN1err(ASN1_F_SMIME_READ_ASN1, | 490 | ASN1error(ASN1_R_SIG_INVALID_MIME_TYPE); |
497 | ASN1_R_SIG_INVALID_MIME_TYPE); | ||
498 | ERR_asprintf_error_data("type: %s", hdr->value); | 491 | ERR_asprintf_error_data("type: %s", hdr->value); |
499 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); | 492 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
500 | sk_BIO_pop_free(parts, BIO_vfree); | 493 | sk_BIO_pop_free(parts, BIO_vfree); |
@@ -503,8 +496,7 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) | |||
503 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); | 496 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
504 | /* Read in ASN1 */ | 497 | /* Read in ASN1 */ |
505 | if (!(val = b64_read_asn1(asnin, it))) { | 498 | if (!(val = b64_read_asn1(asnin, it))) { |
506 | ASN1err(ASN1_F_SMIME_READ_ASN1, | 499 | ASN1error(ASN1_R_ASN1_SIG_PARSE_ERROR); |
507 | ASN1_R_ASN1_SIG_PARSE_ERROR); | ||
508 | sk_BIO_pop_free(parts, BIO_vfree); | 500 | sk_BIO_pop_free(parts, BIO_vfree); |
509 | return NULL; | 501 | return NULL; |
510 | } | 502 | } |
@@ -521,7 +513,7 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) | |||
521 | 513 | ||
522 | if (strcmp (hdr->value, "application/x-pkcs7-mime") && | 514 | if (strcmp (hdr->value, "application/x-pkcs7-mime") && |
523 | strcmp (hdr->value, "application/pkcs7-mime")) { | 515 | strcmp (hdr->value, "application/pkcs7-mime")) { |
524 | ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_INVALID_MIME_TYPE); | 516 | ASN1error(ASN1_R_INVALID_MIME_TYPE); |
525 | ERR_asprintf_error_data("type: %s", hdr->value); | 517 | ERR_asprintf_error_data("type: %s", hdr->value); |
526 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); | 518 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
527 | return NULL; | 519 | return NULL; |
@@ -530,7 +522,7 @@ SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) | |||
530 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); | 522 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
531 | 523 | ||
532 | if (!(val = b64_read_asn1(bio, it))) { | 524 | if (!(val = b64_read_asn1(bio, it))) { |
533 | ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_ASN1_PARSE_ERROR); | 525 | ASN1error(ASN1_R_ASN1_PARSE_ERROR); |
534 | return NULL; | 526 | return NULL; |
535 | } | 527 | } |
536 | return val; | 528 | return val; |
@@ -583,16 +575,16 @@ SMIME_text(BIO *in, BIO *out) | |||
583 | MIME_HEADER *hdr; | 575 | MIME_HEADER *hdr; |
584 | 576 | ||
585 | if (!(headers = mime_parse_hdr(in))) { | 577 | if (!(headers = mime_parse_hdr(in))) { |
586 | ASN1err(ASN1_F_SMIME_TEXT, ASN1_R_MIME_PARSE_ERROR); | 578 | ASN1error(ASN1_R_MIME_PARSE_ERROR); |
587 | return 0; | 579 | return 0; |
588 | } | 580 | } |
589 | if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { | 581 | if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { |
590 | ASN1err(ASN1_F_SMIME_TEXT, ASN1_R_MIME_NO_CONTENT_TYPE); | 582 | ASN1error(ASN1_R_MIME_NO_CONTENT_TYPE); |
591 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); | 583 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
592 | return 0; | 584 | return 0; |
593 | } | 585 | } |
594 | if (strcmp (hdr->value, "text/plain")) { | 586 | if (strcmp (hdr->value, "text/plain")) { |
595 | ASN1err(ASN1_F_SMIME_TEXT, ASN1_R_INVALID_MIME_TYPE); | 587 | ASN1error(ASN1_R_INVALID_MIME_TYPE); |
596 | ERR_asprintf_error_data("type: %s", hdr->value); | 588 | ERR_asprintf_error_data("type: %s", hdr->value); |
597 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); | 589 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
598 | return 0; | 590 | return 0; |