summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/pem/pem_lib.c
diff options
context:
space:
mode:
authormarkus <>2004-04-07 20:42:07 +0000
committermarkus <>2004-04-07 20:42:07 +0000
commit58c08aa241f168c84ce7cc3052454ea59a44eada (patch)
tree1806747a3fda66041a998ca63c763fdcf722450e /src/lib/libcrypto/pem/pem_lib.c
parent9c1aa44a1eacea897c0432e796b205b8484ff4d2 (diff)
downloadopenbsd-58c08aa241f168c84ce7cc3052454ea59a44eada.tar.gz
openbsd-58c08aa241f168c84ce7cc3052454ea59a44eada.tar.bz2
openbsd-58c08aa241f168c84ce7cc3052454ea59a44eada.zip
import openssl-0.9.7d
Diffstat (limited to 'src/lib/libcrypto/pem/pem_lib.c')
-rw-r--r--src/lib/libcrypto/pem/pem_lib.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c
index 70b5446797..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 strcat(buf,"Proc-Type: 4,"); 134 BUF_strlcat(buf,"Proc-Type: 4,",PEM_BUFSIZE);
135 strcat(buf,str); 135 BUF_strlcat(buf,str,PEM_BUFSIZE);
136 strcat(buf,"\n"); 136 BUF_strlcat(buf,"\n",PEM_BUFSIZE);
137 } 137 }
138 138
139void PEM_dek_info(char *buf, const char *type, int len, char *str) 139void PEM_dek_info(char *buf, const char *type, int len, char *str)
@@ -142,10 +142,12 @@ 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 strcat(buf,"DEK-Info: "); 145 BUF_strlcat(buf,"DEK-Info: ",PEM_BUFSIZE);
146 strcat(buf,type); 146 BUF_strlcat(buf,type,PEM_BUFSIZE);
147 strcat(buf,","); 147 BUF_strlcat(buf,",",PEM_BUFSIZE);
148 j=strlen(buf); 148 j=strlen(buf);
149 if (j + (len * 2) + 1 > PEM_BUFSIZE)
150 return;
149 for (i=0; i<len; i++) 151 for (i=0; i<len; i++)
150 { 152 {
151 buf[j+i*2] =map[(str[i]>>4)&0x0f]; 153 buf[j+i*2] =map[(str[i]>>4)&0x0f];
@@ -533,7 +535,7 @@ int PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data,
533 long len) 535 long len)
534 { 536 {
535 int nlen,n,i,j,outl; 537 int nlen,n,i,j,outl;
536 unsigned char *buf; 538 unsigned char *buf = NULL;
537 EVP_ENCODE_CTX ctx; 539 EVP_ENCODE_CTX ctx;
538 int reason=ERR_R_BUF_LIB; 540 int reason=ERR_R_BUF_LIB;
539 541
@@ -553,7 +555,7 @@ int PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data,
553 goto err; 555 goto err;
554 } 556 }
555 557
556 buf=(unsigned char *)OPENSSL_malloc(PEM_BUFSIZE*8); 558 buf = OPENSSL_malloc(PEM_BUFSIZE*8);
557 if (buf == NULL) 559 if (buf == NULL)
558 { 560 {
559 reason=ERR_R_MALLOC_FAILURE; 561 reason=ERR_R_MALLOC_FAILURE;
@@ -574,12 +576,15 @@ int PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data,
574 EVP_EncodeFinal(&ctx,buf,&outl); 576 EVP_EncodeFinal(&ctx,buf,&outl);
575 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;
576 OPENSSL_free(buf); 578 OPENSSL_free(buf);
579 buf = NULL;
577 if ( (BIO_write(bp,"-----END ",9) != 9) || 580 if ( (BIO_write(bp,"-----END ",9) != 9) ||
578 (BIO_write(bp,name,nlen) != nlen) || 581 (BIO_write(bp,name,nlen) != nlen) ||
579 (BIO_write(bp,"-----\n",6) != 6)) 582 (BIO_write(bp,"-----\n",6) != 6))
580 goto err; 583 goto err;
581 return(i+outl); 584 return(i+outl);
582err: 585err:
586 if (buf)
587 OPENSSL_free(buf);
583 PEMerr(PEM_F_PEM_WRITE_BIO,reason); 588 PEMerr(PEM_F_PEM_WRITE_BIO,reason);
584 return(0); 589 return(0);
585 } 590 }