diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/asn_mime.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/asn_mime.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/lib/libcrypto/asn1/asn_mime.c b/src/lib/libcrypto/asn1/asn_mime.c index 54a704a969..c1d1b12291 100644 --- a/src/lib/libcrypto/asn1/asn_mime.c +++ b/src/lib/libcrypto/asn1/asn_mime.c | |||
| @@ -377,12 +377,8 @@ static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags, | |||
| 377 | BIO *tmpbio; | 377 | BIO *tmpbio; |
| 378 | const ASN1_AUX *aux = it->funcs; | 378 | const ASN1_AUX *aux = it->funcs; |
| 379 | ASN1_STREAM_ARG sarg; | 379 | ASN1_STREAM_ARG sarg; |
| 380 | int rv = 1; | ||
| 381 | 380 | ||
| 382 | /* If data is not deteched or resigning then the output BIO is | 381 | if (!(flags & SMIME_DETACHED)) |
| 383 | * already set up to finalise when it is written through. | ||
| 384 | */ | ||
| 385 | if (!(flags & SMIME_DETACHED) || (flags & PKCS7_REUSE_DIGEST)) | ||
| 386 | { | 382 | { |
| 387 | SMIME_crlf_copy(data, out, flags); | 383 | SMIME_crlf_copy(data, out, flags); |
| 388 | return 1; | 384 | return 1; |
| @@ -409,7 +405,7 @@ static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags, | |||
| 409 | 405 | ||
| 410 | /* Finalize structure */ | 406 | /* Finalize structure */ |
| 411 | if (aux->asn1_cb(ASN1_OP_DETACHED_POST, &val, it, &sarg) <= 0) | 407 | if (aux->asn1_cb(ASN1_OP_DETACHED_POST, &val, it, &sarg) <= 0) |
| 412 | rv = 0; | 408 | return 0; |
| 413 | 409 | ||
| 414 | /* Now remove any digests prepended to the BIO */ | 410 | /* Now remove any digests prepended to the BIO */ |
| 415 | 411 | ||
| @@ -420,7 +416,7 @@ static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags, | |||
| 420 | sarg.ndef_bio = tmpbio; | 416 | sarg.ndef_bio = tmpbio; |
| 421 | } | 417 | } |
| 422 | 418 | ||
| 423 | return rv; | 419 | return 1; |
| 424 | 420 | ||
| 425 | } | 421 | } |
| 426 | 422 | ||
| @@ -490,9 +486,9 @@ ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) | |||
| 490 | 486 | ||
| 491 | if(strcmp(hdr->value, "application/x-pkcs7-signature") && | 487 | if(strcmp(hdr->value, "application/x-pkcs7-signature") && |
| 492 | strcmp(hdr->value, "application/pkcs7-signature")) { | 488 | strcmp(hdr->value, "application/pkcs7-signature")) { |
| 489 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); | ||
| 493 | ASN1err(ASN1_F_SMIME_READ_ASN1,ASN1_R_SIG_INVALID_MIME_TYPE); | 490 | ASN1err(ASN1_F_SMIME_READ_ASN1,ASN1_R_SIG_INVALID_MIME_TYPE); |
| 494 | ERR_add_error_data(2, "type: ", hdr->value); | 491 | ERR_add_error_data(2, "type: ", hdr->value); |
| 495 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); | ||
| 496 | sk_BIO_pop_free(parts, BIO_vfree); | 492 | sk_BIO_pop_free(parts, BIO_vfree); |
| 497 | return NULL; | 493 | return NULL; |
| 498 | } | 494 | } |
| @@ -805,7 +801,7 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value) | |||
| 805 | if(name) { | 801 | if(name) { |
| 806 | if(!(tmpname = BUF_strdup(name))) return NULL; | 802 | if(!(tmpname = BUF_strdup(name))) return NULL; |
| 807 | for(p = tmpname ; *p; p++) { | 803 | for(p = tmpname ; *p; p++) { |
| 808 | c = (unsigned char)*p; | 804 | c = *p; |
| 809 | if(isupper(c)) { | 805 | if(isupper(c)) { |
| 810 | c = tolower(c); | 806 | c = tolower(c); |
| 811 | *p = c; | 807 | *p = c; |
| @@ -815,7 +811,7 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value) | |||
| 815 | if(value) { | 811 | if(value) { |
| 816 | if(!(tmpval = BUF_strdup(value))) return NULL; | 812 | if(!(tmpval = BUF_strdup(value))) return NULL; |
| 817 | for(p = tmpval ; *p; p++) { | 813 | for(p = tmpval ; *p; p++) { |
| 818 | c = (unsigned char)*p; | 814 | c = *p; |
| 819 | if(isupper(c)) { | 815 | if(isupper(c)) { |
| 820 | c = tolower(c); | 816 | c = tolower(c); |
| 821 | *p = c; | 817 | *p = c; |
| @@ -839,7 +835,7 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value) | |||
| 839 | tmpname = BUF_strdup(name); | 835 | tmpname = BUF_strdup(name); |
| 840 | if(!tmpname) return 0; | 836 | if(!tmpname) return 0; |
| 841 | for(p = tmpname ; *p; p++) { | 837 | for(p = tmpname ; *p; p++) { |
| 842 | c = (unsigned char)*p; | 838 | c = *p; |
| 843 | if(isupper(c)) { | 839 | if(isupper(c)) { |
| 844 | c = tolower(c); | 840 | c = tolower(c); |
| 845 | *p = c; | 841 | *p = c; |
| @@ -862,17 +858,12 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value) | |||
| 862 | static int mime_hdr_cmp(const MIME_HEADER * const *a, | 858 | static int mime_hdr_cmp(const MIME_HEADER * const *a, |
| 863 | const MIME_HEADER * const *b) | 859 | const MIME_HEADER * const *b) |
| 864 | { | 860 | { |
| 865 | if (!(*a)->name || !(*b)->name) | ||
| 866 | return !!(*a)->name - !!(*b)->name; | ||
| 867 | |||
| 868 | return(strcmp((*a)->name, (*b)->name)); | 861 | return(strcmp((*a)->name, (*b)->name)); |
| 869 | } | 862 | } |
| 870 | 863 | ||
| 871 | static int mime_param_cmp(const MIME_PARAM * const *a, | 864 | static int mime_param_cmp(const MIME_PARAM * const *a, |
| 872 | const MIME_PARAM * const *b) | 865 | const MIME_PARAM * const *b) |
| 873 | { | 866 | { |
| 874 | if (!(*a)->param_name || !(*b)->param_name) | ||
| 875 | return !!(*a)->param_name - !!(*b)->param_name; | ||
| 876 | return(strcmp((*a)->param_name, (*b)->param_name)); | 867 | return(strcmp((*a)->param_name, (*b)->param_name)); |
| 877 | } | 868 | } |
| 878 | 869 | ||
