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