diff options
Diffstat (limited to 'src/lib/libcrypto/pem/pem_lib.c')
-rw-r--r-- | src/lib/libcrypto/pem/pem_lib.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c index 3bec2d7e9f..7785039b99 100644 --- a/src/lib/libcrypto/pem/pem_lib.c +++ b/src/lib/libcrypto/pem/pem_lib.c | |||
@@ -131,9 +131,9 @@ void PEM_proc_type(char *buf, int type) | |||
131 | else | 131 | else |
132 | str="BAD-TYPE"; | 132 | str="BAD-TYPE"; |
133 | 133 | ||
134 | strlcat(buf,"Proc-Type: 4,",PEM_BUFSIZE); | 134 | BUF_strlcat(buf,"Proc-Type: 4,",PEM_BUFSIZE); |
135 | strlcat(buf,str,PEM_BUFSIZE); | 135 | BUF_strlcat(buf,str,PEM_BUFSIZE); |
136 | strlcat(buf,"\n",PEM_BUFSIZE); | 136 | BUF_strlcat(buf,"\n",PEM_BUFSIZE); |
137 | } | 137 | } |
138 | 138 | ||
139 | void PEM_dek_info(char *buf, const char *type, int len, char *str) | 139 | void PEM_dek_info(char *buf, const char *type, int len, char *str) |
@@ -142,9 +142,9 @@ void PEM_dek_info(char *buf, const char *type, int len, char *str) | |||
142 | long i; | 142 | long i; |
143 | int j; | 143 | int j; |
144 | 144 | ||
145 | strlcat(buf,"DEK-Info: ",PEM_BUFSIZE); | 145 | BUF_strlcat(buf,"DEK-Info: ",PEM_BUFSIZE); |
146 | strlcat(buf,type,PEM_BUFSIZE); | 146 | BUF_strlcat(buf,type,PEM_BUFSIZE); |
147 | strlcat(buf,",",PEM_BUFSIZE); | 147 | BUF_strlcat(buf,",",PEM_BUFSIZE); |
148 | j=strlen(buf); | 148 | j=strlen(buf); |
149 | if (j + (len * 2) + 1 > PEM_BUFSIZE) | 149 | if (j + (len * 2) + 1 > PEM_BUFSIZE) |
150 | return; | 150 | return; |
@@ -535,7 +535,7 @@ int PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data, | |||
535 | long len) | 535 | long len) |
536 | { | 536 | { |
537 | int nlen,n,i,j,outl; | 537 | int nlen,n,i,j,outl; |
538 | unsigned char *buf; | 538 | unsigned char *buf = NULL; |
539 | EVP_ENCODE_CTX ctx; | 539 | EVP_ENCODE_CTX ctx; |
540 | int reason=ERR_R_BUF_LIB; | 540 | int reason=ERR_R_BUF_LIB; |
541 | 541 | ||
@@ -555,7 +555,7 @@ int PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data, | |||
555 | goto err; | 555 | goto err; |
556 | } | 556 | } |
557 | 557 | ||
558 | buf=(unsigned char *)OPENSSL_malloc(PEM_BUFSIZE*8); | 558 | buf = OPENSSL_malloc(PEM_BUFSIZE*8); |
559 | if (buf == NULL) | 559 | if (buf == NULL) |
560 | { | 560 | { |
561 | reason=ERR_R_MALLOC_FAILURE; | 561 | reason=ERR_R_MALLOC_FAILURE; |
@@ -576,12 +576,15 @@ int PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data, | |||
576 | EVP_EncodeFinal(&ctx,buf,&outl); | 576 | EVP_EncodeFinal(&ctx,buf,&outl); |
577 | if ((outl > 0) && (BIO_write(bp,(char *)buf,outl) != outl)) goto err; | 577 | if ((outl > 0) && (BIO_write(bp,(char *)buf,outl) != outl)) goto err; |
578 | OPENSSL_free(buf); | 578 | OPENSSL_free(buf); |
579 | buf = NULL; | ||
579 | if ( (BIO_write(bp,"-----END ",9) != 9) || | 580 | if ( (BIO_write(bp,"-----END ",9) != 9) || |
580 | (BIO_write(bp,name,nlen) != nlen) || | 581 | (BIO_write(bp,name,nlen) != nlen) || |
581 | (BIO_write(bp,"-----\n",6) != 6)) | 582 | (BIO_write(bp,"-----\n",6) != 6)) |
582 | goto err; | 583 | goto err; |
583 | return(i+outl); | 584 | return(i+outl); |
584 | err: | 585 | err: |
586 | if (buf) | ||
587 | OPENSSL_free(buf); | ||
585 | PEMerr(PEM_F_PEM_WRITE_BIO,reason); | 588 | PEMerr(PEM_F_PEM_WRITE_BIO,reason); |
586 | return(0); | 589 | return(0); |
587 | } | 590 | } |