Recent and not so recent changes from 0.9.7-stable, all conflicts resolved.

This commit is contained in:
Richard Levitte 2004-01-19 08:53:02 +00:00
parent 7995627040
commit 8b79f2051d
120 changed files with 437 additions and 289 deletions

View File

@ -121,7 +121,7 @@ tags:
tests: tests:
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
lint: lint:
lint -DLINT $(INCLUDES) $(SRC)>fluff lint -DLINT $(INCLUDES) $(SRC)>fluff

View File

@ -1385,14 +1385,16 @@ int load_config(BIO *err, CONF *cnf)
char *make_config_name() char *make_config_name()
{ {
const char *t=X509_get_default_cert_area(); const char *t=X509_get_default_cert_area();
size_t len;
char *p; char *p;
p=OPENSSL_malloc(strlen(t)+strlen(OPENSSL_CONF)+2); len=strlen(t)+strlen(OPENSSL_CONF)+2;
strcpy(p,t); p=OPENSSL_malloc(len);
BUF_strlcpy(p,t,len);
#ifndef OPENSSL_SYS_VMS #ifndef OPENSSL_SYS_VMS
strcat(p,"/"); BUF_strlcat(p,"/",len);
#endif #endif
strcat(p,OPENSSL_CONF); BUF_strlcat(p,OPENSSL_CONF,len);
return p; return p;
} }

View File

@ -569,16 +569,19 @@ bad:
if (configfile == NULL) if (configfile == NULL)
{ {
const char *s=X509_get_default_cert_area(); const char *s=X509_get_default_cert_area();
size_t len;
#ifdef OPENSSL_SYS_VMS #ifdef OPENSSL_SYS_VMS
tofree=OPENSSL_malloc(strlen(s)+sizeof(CONFIG_FILE)); len = strlen(s)+sizeof(CONFIG_FILE);
tofree=OPENSSL_malloc(len);
strcpy(tofree,s); strcpy(tofree,s);
#else #else
tofree=OPENSSL_malloc(strlen(s)+sizeof(CONFIG_FILE)+1); len = strlen(s)+sizeof(CONFIG_FILE)+1;
strcpy(tofree,s); tofree=OPENSSL_malloc(len);
strcat(tofree,"/"); BUF_strlcpy(tofree,s,len);
BUF_strlcat(tofree,"/",len);
#endif #endif
strcat(tofree,CONFIG_FILE); BUF_strlcat(tofree,CONFIG_FILE,len);
configfile=tofree; configfile=tofree;
} }
@ -1302,7 +1305,7 @@ bad:
#ifdef OPENSSL_SYS_VMS #ifdef OPENSSL_SYS_VMS
strcat(buf[0],"-new"); strcat(buf[0],"-new");
#else #else
strcat(buf[0],".new"); BUF_strlcat(buf[0],".new",sizeof(buf[0]));
#endif #endif
if (!save_serial(buf[0],serial)) goto err; if (!save_serial(buf[0],serial)) goto err;
@ -1312,7 +1315,7 @@ bad:
#ifdef OPENSSL_SYS_VMS #ifdef OPENSSL_SYS_VMS
strcat(buf[1],"-new"); strcat(buf[1],"-new");
#else #else
strcat(buf[1],".new"); BUF_strlcat(buf[1],".new",sizeof(buf[1]));
#endif #endif
if (BIO_write_filename(out,buf[1]) <= 0) if (BIO_write_filename(out,buf[1]) <= 0)
@ -1330,7 +1333,7 @@ bad:
for (i=0; i<sk_X509_num(cert_sk); i++) for (i=0; i<sk_X509_num(cert_sk); i++)
{ {
int k; int k;
unsigned char *n; char *n;
x=sk_X509_value(cert_sk,i); x=sk_X509_value(cert_sk,i);
@ -1346,15 +1349,19 @@ bad:
strcpy(buf[2],outdir); strcpy(buf[2],outdir);
#ifndef OPENSSL_SYS_VMS #ifndef OPENSSL_SYS_VMS
strcat(buf[2],"/"); BUF_strlcat(buf[2],"/",sizeof(buf[2]));
#endif #endif
n=(unsigned char *)&(buf[2][strlen(buf[2])]); n=(char *)&(buf[2][strlen(buf[2])]);
if (j > 0) if (j > 0)
{ {
for (k=0; k<j; k++) for (k=0; k<j; k++)
{ {
sprintf((char *)n,"%02X",(unsigned char)*(p++)); if (n >= &(buf[2][sizeof(buf[2])]))
break;
BIO_snprintf(n,
&buf[2][0] + sizeof(buf[2]) - n,
"%02X",(unsigned char)*(p++));
n+=2; n+=2;
} }
} }
@ -1386,7 +1393,7 @@ bad:
#ifdef OPENSSL_SYS_VMS #ifdef OPENSSL_SYS_VMS
strcat(buf[2],"-old"); strcat(buf[2],"-old");
#else #else
strcat(buf[2],".old"); BUF_strlcat(buf[2],".old",sizeof(buf[2]));
#endif #endif
BIO_free(in); BIO_free(in);
@ -1415,7 +1422,7 @@ bad:
#ifdef OPENSSL_SYS_VMS #ifdef OPENSSL_SYS_VMS
strcat(buf[2],"-old"); strcat(buf[2],"-old");
#else #else
strcat(buf[2],".old"); BUF_strlcat(buf[2],".old",sizeof(buf[2]));
#endif #endif
if (rename(dbfile,buf[2]) < 0) if (rename(dbfile,buf[2]) < 0)
@ -1585,7 +1592,7 @@ bad:
strcpy(buf[0],dbfile); strcpy(buf[0],dbfile);
#ifndef OPENSSL_SYS_VMS #ifndef OPENSSL_SYS_VMS
strcat(buf[0],".new"); BUF_strlcat(buf[0],".new",sizeof(buf[0]));
#else #else
strcat(buf[0],"-new"); strcat(buf[0],"-new");
#endif #endif
@ -1604,7 +1611,7 @@ bad:
strncpy(buf[1],dbfile,BSIZE-4); strncpy(buf[1],dbfile,BSIZE-4);
buf[1][BSIZE-4]='\0'; buf[1][BSIZE-4]='\0';
#ifndef OPENSSL_SYS_VMS #ifndef OPENSSL_SYS_VMS
strcat(buf[1],".old"); BUF_strlcat(buf[1],".old",sizeof(buf[1]));
#else #else
strcat(buf[1],"-old"); strcat(buf[1],"-old");
#endif #endif
@ -2342,7 +2349,7 @@ again2:
BIO_printf(bio_err,"Memory allocation failure\n"); BIO_printf(bio_err,"Memory allocation failure\n");
goto err; goto err;
} }
strcpy(row[DB_file],"unknown"); BUF_strlcpy(row[DB_file],"unknown",8);
row[DB_type][0]='V'; row[DB_type][0]='V';
row[DB_type][1]='\0'; row[DB_type][1]='\0';
@ -2643,7 +2650,7 @@ static int do_revoke(X509 *x509, TXT_DB *db, int type, char *value)
BIO_printf(bio_err,"Memory allocation failure\n"); BIO_printf(bio_err,"Memory allocation failure\n");
goto err; goto err;
} }
strcpy(row[DB_file],"unknown"); BUF_strlcpy(row[DB_file],"unknown",8);
row[DB_type][0]='V'; row[DB_type][0]='V';
row[DB_type][1]='\0'; row[DB_type][1]='\0';
@ -2967,16 +2974,16 @@ char *make_revocation_str(int rev_type, char *rev_arg)
if (!str) return NULL; if (!str) return NULL;
strcpy(str, (char *)revtm->data); BUF_strlcpy(str, (char *)revtm->data, i);
if (reason) if (reason)
{ {
strcat(str, ","); BUF_strlcat(str, ",", i);
strcat(str, reason); BUF_strlcat(str, reason, i);
} }
if (other) if (other)
{ {
strcat(str, ","); BUF_strlcat(str, ",", i);
strcat(str, other); BUF_strlcat(str, other, i);
} }
ASN1_UTCTIME_free(revtm); ASN1_UTCTIME_free(revtm);
return str; return str;

View File

@ -347,8 +347,9 @@ int MAIN(int argc, char **argv)
} }
if(!out_bin) if(!out_bin)
{ {
tmp=tofree=OPENSSL_malloc(strlen(name)+strlen(argv[i])+5); size_t len = strlen(name)+strlen(argv[i])+5;
sprintf(tmp,"%s(%s)= ",name,argv[i]); tmp=tofree=OPENSSL_malloc(len);
BIO_snprintf(tmp,len,"%s(%s)= ",name,argv[i]);
} }
else else
tmp=""; tmp="";

View File

@ -373,7 +373,7 @@ bad:
{ {
char buf[200]; char buf[200];
sprintf(buf,"enter %s %s password:", BIO_snprintf(buf,sizeof buf,"enter %s %s password:",
OBJ_nid2ln(EVP_CIPHER_nid(cipher)), OBJ_nid2ln(EVP_CIPHER_nid(cipher)),
(enc)?"encryption":"decryption"); (enc)?"encryption":"decryption");
strbuf[0]='\0'; strbuf[0]='\0';

View File

@ -122,8 +122,8 @@ static int append_buf(char **buf, const char *s, int *size, int step)
return 0; return 0;
if (**buf != '\0') if (**buf != '\0')
strcat(*buf, ", "); BUF_strlcat(*buf, ", ", *size);
strcat(*buf, s); BUF_strlcat(*buf, s, *size);
return 1; return 1;
} }

View File

@ -557,7 +557,7 @@ int MAIN(int argc, char **argv)
BIO_printf (bio_err, "Can't read Password\n"); BIO_printf (bio_err, "Can't read Password\n");
goto export_end; goto export_end;
} }
if (!twopass) strcpy(macpass, pass); if (!twopass) BUF_strlcpy(macpass, pass, sizeof macpass);
/* Turn certbags into encrypted authsafe */ /* Turn certbags into encrypted authsafe */
authsafe = PKCS12_pack_p7encdata(cert_pbe, cpass, -1, NULL, 0, authsafe = PKCS12_pack_p7encdata(cert_pbe, cpass, -1, NULL, 0,
iter, bags); iter, bags);
@ -658,7 +658,7 @@ int MAIN(int argc, char **argv)
CRYPTO_pop_info(); CRYPTO_pop_info();
#endif #endif
if (!twopass) strcpy(macpass, pass); if (!twopass) BUF_strlcpy(macpass, pass, sizeof macpass);
if (options & INFO) BIO_printf (bio_err, "MAC Iteration %ld\n", p12->mac->iter ? ASN1_INTEGER_get (p12->mac->iter) : 1); if (options & INFO) BIO_printf (bio_err, "MAC Iteration %ld\n", p12->mac->iter ? ASN1_INTEGER_get (p12->mac->iter) : 1);
if(macver) { if(macver) {

View File

@ -1223,34 +1223,34 @@ start: for (;;)
} }
/* If OBJ not recognised ignore it */ /* If OBJ not recognised ignore it */
if ((nid=OBJ_txt2nid(type)) == NID_undef) goto start; if ((nid=OBJ_txt2nid(type)) == NID_undef) goto start;
if (BIO_snprintf(buf,sizeof buf,"%s_default",v->name)
if(strlen(v->name) > sizeof buf-9) >= sizeof buf)
{ {
BIO_printf(bio_err,"Name '%s' too long\n",v->name); BIO_printf(bio_err,"Name '%s' too long\n",v->name);
return 0; return 0;
} }
sprintf(buf,"%s_default",v->name);
if ((def=NCONF_get_string(req_conf,dn_sect,buf)) == NULL) if ((def=NCONF_get_string(req_conf,dn_sect,buf)) == NULL)
{ {
ERR_clear_error(); ERR_clear_error();
def=""; def="";
} }
sprintf(buf,"%s_value",v->name);
BIO_snprintf(buf,sizeof buf,"%s_value",v->name);
if ((value=NCONF_get_string(req_conf,dn_sect,buf)) == NULL) if ((value=NCONF_get_string(req_conf,dn_sect,buf)) == NULL)
{ {
ERR_clear_error(); ERR_clear_error();
value=NULL; value=NULL;
} }
sprintf(buf,"%s_min",v->name); BIO_snprintf(buf,sizeof buf,"%s_min",v->name);
if (!NCONF_get_number(req_conf,dn_sect,buf, &n_min)) if (!NCONF_get_number(req_conf,dn_sect,buf, &n_min))
{ {
ERR_clear_error(); ERR_clear_error();
n_min = -1; n_min = -1;
} }
sprintf(buf,"%s_max",v->name); BIO_snprintf(buf,sizeof buf,"%s_max",v->name);
if (!NCONF_get_number(req_conf,dn_sect,buf, &n_max)) if (!NCONF_get_number(req_conf,dn_sect,buf, &n_max))
{ {
ERR_clear_error(); ERR_clear_error();
@ -1288,13 +1288,13 @@ start2: for (;;)
if ((nid=OBJ_txt2nid(type)) == NID_undef) if ((nid=OBJ_txt2nid(type)) == NID_undef)
goto start2; goto start2;
if(strlen(v->name) > sizeof buf-9) if (BIO_snprintf(buf,sizeof buf,"%s_default",type)
>= sizeof buf)
{ {
BIO_printf(bio_err,"Name '%s' too long\n",v->name); BIO_printf(bio_err,"Name '%s' too long\n",v->name);
return 0; return 0;
} }
sprintf(buf,"%s_default",type);
if ((def=NCONF_get_string(req_conf,attr_sect,buf)) if ((def=NCONF_get_string(req_conf,attr_sect,buf))
== NULL) == NULL)
{ {
@ -1303,7 +1303,7 @@ start2: for (;;)
} }
sprintf(buf,"%s_value",type); BIO_snprintf(buf,sizeof buf,"%s_value",type);
if ((value=NCONF_get_string(req_conf,attr_sect,buf)) if ((value=NCONF_get_string(req_conf,attr_sect,buf))
== NULL) == NULL)
{ {
@ -1311,11 +1311,11 @@ start2: for (;;)
value=NULL; value=NULL;
} }
sprintf(buf,"%s_min",type); BIO_snprintf(buf,sizeof buf,"%s_min",type);
if (!NCONF_get_number(req_conf,attr_sect,buf, &n_min)) if (!NCONF_get_number(req_conf,attr_sect,buf, &n_min))
n_min = -1; n_min = -1;
sprintf(buf,"%s_max",type); BIO_snprintf(buf,sizeof buf,"%s_max",type);
if (!NCONF_get_number(req_conf,attr_sect,buf, &n_max)) if (!NCONF_get_number(req_conf,attr_sect,buf, &n_max))
n_max = -1; n_max = -1;
@ -1397,9 +1397,8 @@ start:
(void)BIO_flush(bio_err); (void)BIO_flush(bio_err);
if(value != NULL) if(value != NULL)
{ {
OPENSSL_assert(strlen(value) < sizeof buf-2); BUF_strlcpy(buf,value,sizeof buf);
strcpy(buf,value); BUF_strlcat(buf,"\n",sizeof buf);
strcat(buf,"\n");
BIO_printf(bio_err,"%s\n",value); BIO_printf(bio_err,"%s\n",value);
} }
else else
@ -1421,8 +1420,8 @@ start:
{ {
if ((def == NULL) || (def[0] == '\0')) if ((def == NULL) || (def[0] == '\0'))
return(1); return(1);
strcpy(buf,def); BUF_strlcpy(buf,def,sizeof buf);
strcat(buf,"\n"); BUF_strlcat(buf,"\n",sizeof buf);
} }
else if ((buf[0] == '.') && (buf[1] == '\n')) return(1); else if ((buf[0] == '.') && (buf[1] == '\n')) return(1);
@ -1456,9 +1455,8 @@ start:
(void)BIO_flush(bio_err); (void)BIO_flush(bio_err);
if (value != NULL) if (value != NULL)
{ {
OPENSSL_assert(strlen(value) < sizeof buf-2); BUF_strlcpy(buf,value,sizeof buf);
strcpy(buf,value); BUF_strlcat(buf,"\n",sizeof buf);
strcat(buf,"\n");
BIO_printf(bio_err,"%s\n",value); BIO_printf(bio_err,"%s\n",value);
} }
else else
@ -1480,8 +1478,8 @@ start:
{ {
if ((def == NULL) || (def[0] == '\0')) if ((def == NULL) || (def[0] == '\0'))
return(1); return(1);
strcpy(buf,def); BUF_strlcpy(buf,def,sizeof buf);
strcat(buf,"\n"); BUF_strlcat(buf,"\n",sizeof buf);
} }
else if ((buf[0] == '.') && (buf[1] == '\n')) return(1); else if ((buf[0] == '.') && (buf[1] == '\n')) return(1);

View File

@ -389,7 +389,7 @@ redoit:
perror("OPENSSL_malloc"); perror("OPENSSL_malloc");
return(0); return(0);
} }
strcpy(*host,h1->h_name); BUF_strlcpy(*host,h1->h_name,strlen(h1->h_name)+1);
h2=GetHostByName(*host); h2=GetHostByName(*host);
if (h2 == NULL) if (h2 == NULL)

View File

@ -502,7 +502,7 @@ int MAIN(int argc, char **argv)
if (s_www_path != NULL) if (s_www_path != NULL)
{ {
sprintf(buf,"GET %s HTTP/1.0\r\n\r\n",s_www_path); BIO_snprintf(buf,sizeof buf,"GET %s HTTP/1.0\r\n\r\n",s_www_path);
SSL_write(scon,buf,strlen(buf)); SSL_write(scon,buf,strlen(buf));
while ((i=SSL_read(scon,buf,sizeof(buf))) > 0) while ((i=SSL_read(scon,buf,sizeof(buf))) > 0)
bytes_read+=i; bytes_read+=i;
@ -557,7 +557,7 @@ next:
if (s_www_path != NULL) if (s_www_path != NULL)
{ {
sprintf(buf,"GET %s HTTP/1.0\r\n\r\n",s_www_path); BIO_snprintf(buf,sizeof buf,"GET %s HTTP/1.0\r\n\r\n",s_www_path);
SSL_write(scon,buf,strlen(buf)); SSL_write(scon,buf,strlen(buf));
while (SSL_read(scon,buf,sizeof(buf)) > 0) while (SSL_read(scon,buf,sizeof(buf)) > 0)
; ;
@ -595,7 +595,7 @@ next:
if (s_www_path) if (s_www_path)
{ {
sprintf(buf,"GET %s HTTP/1.0\r\n\r\n",s_www_path); BIO_snprintf(buf,sizeof buf,"GET %s HTTP/1.0\r\n\r\n",s_www_path);
SSL_write(scon,buf,strlen(buf)); SSL_write(scon,buf,strlen(buf));
while ((i=SSL_read(scon,buf,sizeof(buf))) > 0) while ((i=SSL_read(scon,buf,sizeof(buf))) > 0)
bytes_read+=i; bytes_read+=i;

View File

@ -773,6 +773,7 @@ int MAIN(int argc, char **argv)
{ {
dsa_doit[R_DSA_512]=1; dsa_doit[R_DSA_512]=1;
dsa_doit[R_DSA_1024]=1; dsa_doit[R_DSA_1024]=1;
dsa_doit[R_DSA_2048]=1;
} }
else else
#endif #endif

View File

@ -1029,24 +1029,26 @@ static ASN1_INTEGER *load_serial(char *CAfile, char *serialfile, int create)
ASN1_INTEGER *bs = NULL, *bs2 = NULL; ASN1_INTEGER *bs = NULL, *bs2 = NULL;
BIO *io = NULL; BIO *io = NULL;
BIGNUM *serial = NULL; BIGNUM *serial = NULL;
size_t len;
buf=OPENSSL_malloc( ((serialfile == NULL) len = ((serialfile == NULL)
?(strlen(CAfile)+strlen(POSTFIX)+1) ?(strlen(CAfile)+strlen(POSTFIX)+1)
:(strlen(serialfile)))+1); :(strlen(serialfile)))+1;
buf=OPENSSL_malloc(len);
if (buf == NULL) { BIO_printf(bio_err,"out of mem\n"); goto end; } if (buf == NULL) { BIO_printf(bio_err,"out of mem\n"); goto end; }
if (serialfile == NULL) if (serialfile == NULL)
{ {
strcpy(buf,CAfile); BUF_strlcpy(buf,CAfile,len);
for (p=buf; *p; p++) for (p=buf; *p; p++)
if (*p == '.') if (*p == '.')
{ {
*p='\0'; *p='\0';
break; break;
} }
strcat(buf,POSTFIX); BUF_strlcat(buf,POSTFIX,len);
} }
else else
strcpy(buf,serialfile); BUF_strlcpy(buf,serialfile,len);
serial=BN_new(); serial=BN_new();
bs=ASN1_INTEGER_new(); bs=ASN1_INTEGER_new();
if ((serial == NULL) || (bs == NULL)) if ((serial == NULL) || (bs == NULL))

View File

@ -81,11 +81,11 @@ files:
done; done;
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../apps $(APPS)
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@for i in $(SDIRS); do \ @for i in $(SDIRS); do \
(cd $$i && echo "making links in crypto/$$i..." && \ (cd $$i && echo "making links in crypto/$$i..." && \
$(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PERL='${PERL}' links ); \ $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' PERL='${PERL}' links ); \

View File

@ -52,7 +52,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -77,7 +77,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -208,6 +208,7 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
char *p; char *p;
struct tm *ts; struct tm *ts;
struct tm data; struct tm data;
size_t len = 20;
if (s == NULL) if (s == NULL)
s=M_ASN1_GENERALIZEDTIME_new(); s=M_ASN1_GENERALIZEDTIME_new();
@ -219,16 +220,16 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
return(NULL); return(NULL);
p=(char *)s->data; p=(char *)s->data;
if ((p == NULL) || (s->length < 16)) if ((p == NULL) || (s->length < len))
{ {
p=OPENSSL_malloc(20); p=OPENSSL_malloc(len);
if (p == NULL) return(NULL); if (p == NULL) return(NULL);
if (s->data != NULL) if (s->data != NULL)
OPENSSL_free(s->data); OPENSSL_free(s->data);
s->data=(unsigned char *)p; s->data=(unsigned char *)p;
} }
sprintf(p,"%04d%02d%02d%02d%02d%02dZ",ts->tm_year + 1900, BIO_snprintf(p,len,"%04d%02d%02d%02d%02d%02dZ",ts->tm_year + 1900,
ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec); ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec);
s->length=strlen(p); s->length=strlen(p);
s->type=V_ASN1_GENERALIZEDTIME; s->type=V_ASN1_GENERALIZEDTIME;

View File

@ -145,14 +145,14 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
if((minsize > 0) && (nchar < minsize)) { if((minsize > 0) && (nchar < minsize)) {
ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_SHORT); ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_SHORT);
sprintf(strbuf, "%ld", minsize); BIO_snprintf(strbuf, sizeof strbuf, "%ld", minsize);
ERR_add_error_data(2, "minsize=", strbuf); ERR_add_error_data(2, "minsize=", strbuf);
return -1; return -1;
} }
if((maxsize > 0) && (nchar > maxsize)) { if((maxsize > 0) && (nchar > maxsize)) {
ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_LONG); ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_LONG);
sprintf(strbuf, "%ld", maxsize); BIO_snprintf(strbuf, sizeof strbuf, "%ld", maxsize);
ERR_add_error_data(2, "maxsize=", strbuf); ERR_add_error_data(2, "maxsize=", strbuf);
return -1; return -1;
} }

View File

@ -129,6 +129,7 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t,
{ {
ASN1_GENERALIZEDTIME *ret; ASN1_GENERALIZEDTIME *ret;
char *str; char *str;
int newlen;
if (!ASN1_TIME_check(t)) return NULL; if (!ASN1_TIME_check(t)) return NULL;
@ -151,12 +152,14 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t,
/* grow the string */ /* grow the string */
if (!ASN1_STRING_set(ret, NULL, t->length + 2)) if (!ASN1_STRING_set(ret, NULL, t->length + 2))
return NULL; return NULL;
/* ASN1_STRING_set() allocated 'len + 1' bytes. */
newlen = t->length + 2 + 1;
str = (char *)ret->data; str = (char *)ret->data;
/* Work out the century and prepend */ /* Work out the century and prepend */
if (t->data[0] >= '5') strcpy(str, "19"); if (t->data[0] >= '5') BUF_strlcpy(str, "19", newlen);
else strcpy(str, "20"); else BUF_strlcpy(str, "20", newlen);
BUF_strlcat(str, (char *)t->data, t->length+3); /* Include space for a '\0' */ BUF_strlcat(str, (char *)t->data, newlen);
return ret; return ret;
} }

View File

@ -188,6 +188,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
char *p; char *p;
struct tm *ts; struct tm *ts;
struct tm data; struct tm data;
size_t len = 20;
if (s == NULL) if (s == NULL)
s=M_ASN1_UTCTIME_new(); s=M_ASN1_UTCTIME_new();
@ -199,16 +200,16 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
return(NULL); return(NULL);
p=(char *)s->data; p=(char *)s->data;
if ((p == NULL) || (s->length < 14)) if ((p == NULL) || (s->length < len))
{ {
p=OPENSSL_malloc(20); p=OPENSSL_malloc(len);
if (p == NULL) return(NULL); if (p == NULL) return(NULL);
if (s->data != NULL) if (s->data != NULL)
OPENSSL_free(s->data); OPENSSL_free(s->data);
s->data=(unsigned char *)p; s->data=(unsigned char *)p;
} }
sprintf(p,"%02d%02d%02d%02d%02d%02dZ",ts->tm_year%100, BIO_snprintf(p,len,"%02d%02d%02d%02d%02d%02dZ",ts->tm_year%100,
ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec); ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec);
s->length=strlen(p); s->length=strlen(p);
s->type=V_ASN1_UTCTIME; s->type=V_ASN1_UTCTIME;

View File

@ -414,8 +414,8 @@ void asn1_add_error(unsigned char *address, int offset)
{ {
char buf1[DECIMAL_SIZE(address)+1],buf2[DECIMAL_SIZE(offset)+1]; char buf1[DECIMAL_SIZE(address)+1],buf2[DECIMAL_SIZE(offset)+1];
sprintf(buf1,"%lu",(unsigned long)address); BIO_snprintf(buf1,sizeof buf1,"%lu",(unsigned long)address);
sprintf(buf2,"%d",offset); BIO_snprintf(buf2,sizeof buf2,"%d",offset);
ERR_add_error_data(4,"address=",buf1," offset=",buf2); ERR_add_error_data(4,"address=",buf1," offset=",buf2);
} }

View File

@ -83,11 +83,11 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
p=str; p=str;
if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE) if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
sprintf(str,"priv [ %d ] ",tag); BIO_snprintf(str,sizeof str,"priv [ %d ] ",tag);
else if ((xclass & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC) else if ((xclass & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
sprintf(str,"cont [ %d ]",tag); BIO_snprintf(str,sizeof str,"cont [ %d ]",tag);
else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION) else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
sprintf(str,"appl [ %d ]",tag); BIO_snprintf(str,sizeof str,"appl [ %d ]",tag);
else p = ASN1_tag2str(tag); else p = ASN1_tag2str(tag);
if (p2 != NULL) if (p2 != NULL)

View File

@ -139,9 +139,9 @@ int RSA_print(BIO *bp, const RSA *x, int off)
} }
if (x->d == NULL) if (x->d == NULL)
sprintf(str,"Modulus (%d bit):",BN_num_bits(x->n)); BIO_snprintf(str,sizeof str,"Modulus (%d bit):",BN_num_bits(x->n));
else else
strcpy(str,"modulus:"); BUF_strlcpy(str,"modulus:",sizeof str);
if (!print(bp,str,x->n,m,off)) goto err; if (!print(bp,str,x->n,m,off)) goto err;
s=(x->d == NULL)?"Exponent:":"publicExponent:"; s=(x->d == NULL)?"Exponent:":"publicExponent:";
if (!print(bp,s,x->e,m,off)) goto err; if (!print(bp,s,x->e,m,off)) goto err;

View File

@ -104,7 +104,12 @@ static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const A
long ltmp; long ltmp;
unsigned long utmp; unsigned long utmp;
int clen, pad, i; int clen, pad, i;
ltmp = *(long *)pval; /* this exists to bypass broken gcc optimization */
char *cp = (char *)pval;
/* use memcpy, because we may not be long aligned */
memcpy(&ltmp, cp, sizeof(long));
if(ltmp == it->size) return -1; if(ltmp == it->size) return -1;
/* Convert the long to positive: we subtract one if negative so /* Convert the long to positive: we subtract one if negative so
* we can cleanly handle the padding if only the MSB of the leading * we can cleanly handle the padding if only the MSB of the leading
@ -136,6 +141,7 @@ static int long_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype,
int neg, i; int neg, i;
long ltmp; long ltmp;
unsigned long utmp = 0; unsigned long utmp = 0;
char *cp = (char *)pval;
if(len > sizeof(long)) { if(len > sizeof(long)) {
ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG);
return 0; return 0;
@ -158,6 +164,6 @@ static int long_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype,
ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG);
return 0; return 0;
} }
*(long *)pval = ltmp; memcpy(cp, &ltmp, sizeof(long));
return 1; return 1;
} }

View File

@ -68,7 +68,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -57,7 +57,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -104,38 +104,41 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
for(i=0;i<rows;i++) for(i=0;i<rows;i++)
{ {
buf[0]='\0'; /* start with empty string */ buf[0]='\0'; /* start with empty string */
strcpy(buf,str); BUF_strlcpy(buf,str,sizeof buf);
sprintf(tmp,"%04x - ",i*dump_width); BIO_snprintf(tmp,sizeof tmp,"%04x - ",i*dump_width);
strcat(buf,tmp); BUF_strlcat(buf,tmp,sizeof buf);
for(j=0;j<dump_width;j++) for(j=0;j<dump_width;j++)
{ {
if (((i*dump_width)+j)>=len) if (((i*dump_width)+j)>=len)
{ {
strcat(buf," "); BUF_strlcat(buf," ",sizeof buf);
} }
else else
{ {
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
sprintf(tmp,"%02x%c",ch,j==7?'-':' '); BIO_snprintf(tmp,sizeof tmp,"%02x%c",ch,
strcat(buf,tmp); j==7?'-':' ');
BUF_strlcat(buf,tmp,sizeof buf);
} }
} }
strcat(buf," "); BUF_strlcat(buf," ",sizeof buf);
for(j=0;j<dump_width;j++) for(j=0;j<dump_width;j++)
{ {
if (((i*dump_width)+j)>=len) if (((i*dump_width)+j)>=len)
break; break;
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
#ifndef CHARSET_EBCDIC #ifndef CHARSET_EBCDIC
sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.'); BIO_snprintf(tmp,sizeof tmp,"%c",
((ch>=' ')&&(ch<='~'))?ch:'.');
#else #else
sprintf(tmp,"%c",((ch>=os_toascii[' '])&&(ch<=os_toascii['~'])) BIO_snprintf(tmp,sizeof tmp,"%c",
((ch>=os_toascii[' '])&&(ch<=os_toascii['~']))
? os_toebcdic[ch] ? os_toebcdic[ch]
: '.'); : '.');
#endif #endif
strcat(buf,tmp); BUF_strlcat(buf,tmp,sizeof buf);
} }
strcat(buf,"\n"); BUF_strlcat(buf,"\n",sizeof buf);
/* if this is the last call then update the ddt_dump thing so that /* if this is the last call then update the ddt_dump thing so that
* we will move the selection point in the debug window * we will move the selection point in the debug window
*/ */
@ -144,7 +147,8 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
#ifdef TRUNCATE #ifdef TRUNCATE
if (trunc > 0) if (trunc > 0)
{ {
sprintf(buf,"%s%04x - <SPACES/NULS>\n",str,len+trunc); BIO_snprintf(buf,sizeof buf,"%s%04x - <SPACES/NULS>\n",str,
len+trunc);
ret+=BIO_write(bio,(char *)buf,strlen(buf)); ret+=BIO_write(bio,(char *)buf,strlen(buf));
} }
#endif #endif

View File

@ -576,12 +576,12 @@ abs_val(LDOUBLE value)
} }
static LDOUBLE static LDOUBLE
pow10(int exp) pow10(int in_exp)
{ {
LDOUBLE result = 1; LDOUBLE result = 1;
while (exp) { while (in_exp) {
result *= 10; result *= 10;
exp--; in_exp--;
} }
return result; return result;
} }

View File

@ -709,7 +709,7 @@ int BIO_accept(int sock, char **addr)
} }
*addr=p; *addr=p;
} }
sprintf(*addr,"%d.%d.%d.%d:%d", BIO_snprintf(*addr,24,"%d.%d.%d.%d:%d",
(unsigned char)(l>>24L)&0xff, (unsigned char)(l>>24L)&0xff,
(unsigned char)(l>>16L)&0xff, (unsigned char)(l>>16L)&0xff,
(unsigned char)(l>> 8L)&0xff, (unsigned char)(l>> 8L)&0xff,

View File

@ -70,55 +70,61 @@ long MS_CALLBACK BIO_debug_callback(BIO *bio, int cmd, const char *argp,
MS_STATIC char buf[256]; MS_STATIC char buf[256];
char *p; char *p;
long r=1; long r=1;
size_t p_maxlen;
if (BIO_CB_RETURN & cmd) if (BIO_CB_RETURN & cmd)
r=ret; r=ret;
sprintf(buf,"BIO[%08lX]:",(unsigned long)bio); BIO_snprintf(buf,sizeof buf,"BIO[%08lX]:",(unsigned long)bio);
p= &(buf[14]); p= &(buf[14]);
p_maxlen = sizeof buf - 14;
switch (cmd) switch (cmd)
{ {
case BIO_CB_FREE: case BIO_CB_FREE:
sprintf(p,"Free - %s\n",bio->method->name); BIO_snprintf(p,p_maxlen,"Free - %s\n",bio->method->name);
break; break;
case BIO_CB_READ: case BIO_CB_READ:
if (bio->method->type & BIO_TYPE_DESCRIPTOR) if (bio->method->type & BIO_TYPE_DESCRIPTOR)
sprintf(p,"read(%d,%d) - %s fd=%d\n",bio->num,argi,bio->method->name,bio->num); BIO_snprintf(p,p_maxlen,"read(%d,%d) - %s fd=%d\n",
bio->num,argi,bio->method->name,bio->num);
else else
sprintf(p,"read(%d,%d) - %s\n",bio->num,argi,bio->method->name); BIO_snprintf(p,p_maxlen,"read(%d,%d) - %s\n",
bio->num,argi,bio->method->name);
break; break;
case BIO_CB_WRITE: case BIO_CB_WRITE:
if (bio->method->type & BIO_TYPE_DESCRIPTOR) if (bio->method->type & BIO_TYPE_DESCRIPTOR)
sprintf(p,"write(%d,%d) - %s fd=%d\n",bio->num,argi,bio->method->name,bio->num); BIO_snprintf(p,p_maxlen,"write(%d,%d) - %s fd=%d\n",
bio->num,argi,bio->method->name,bio->num);
else else
sprintf(p,"write(%d,%d) - %s\n",bio->num,argi,bio->method->name); BIO_snprintf(p,p_maxlen,"write(%d,%d) - %s\n",
bio->num,argi,bio->method->name);
break; break;
case BIO_CB_PUTS: case BIO_CB_PUTS:
sprintf(p,"puts() - %s\n",bio->method->name); BIO_snprintf(p,p_maxlen,"puts() - %s\n",bio->method->name);
break; break;
case BIO_CB_GETS: case BIO_CB_GETS:
sprintf(p,"gets(%d) - %s\n",argi,bio->method->name); BIO_snprintf(p,p_maxlen,"gets(%d) - %s\n",argi,bio->method->name);
break; break;
case BIO_CB_CTRL: case BIO_CB_CTRL:
sprintf(p,"ctrl(%d) - %s\n",argi,bio->method->name); BIO_snprintf(p,p_maxlen,"ctrl(%d) - %s\n",argi,bio->method->name);
break; break;
case BIO_CB_RETURN|BIO_CB_READ: case BIO_CB_RETURN|BIO_CB_READ:
sprintf(p,"read return %ld\n",ret); BIO_snprintf(p,p_maxlen,"read return %ld\n",ret);
break; break;
case BIO_CB_RETURN|BIO_CB_WRITE: case BIO_CB_RETURN|BIO_CB_WRITE:
sprintf(p,"write return %ld\n",ret); BIO_snprintf(p,p_maxlen,"write return %ld\n",ret);
break; break;
case BIO_CB_RETURN|BIO_CB_GETS: case BIO_CB_RETURN|BIO_CB_GETS:
sprintf(p,"gets return %ld\n",ret); BIO_snprintf(p,p_maxlen,"gets return %ld\n",ret);
break; break;
case BIO_CB_RETURN|BIO_CB_PUTS: case BIO_CB_RETURN|BIO_CB_PUTS:
sprintf(p,"puts return %ld\n",ret); BIO_snprintf(p,p_maxlen,"puts return %ld\n",ret);
break; break;
case BIO_CB_RETURN|BIO_CB_CTRL: case BIO_CB_RETURN|BIO_CB_CTRL:
sprintf(p,"ctrl return %ld\n",ret); BIO_snprintf(p,p_maxlen,"ctrl return %ld\n",ret);
break; break;
default: default:
sprintf(p,"bio callback - unknown type (%d)\n",cmd); BIO_snprintf(p,p_maxlen,"bio callback - unknown type (%d)\n",cmd);
break; break;
} }

View File

@ -521,7 +521,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
char buf[16]; char buf[16];
unsigned char *p = ptr; unsigned char *p = ptr;
sprintf(buf,"%d.%d.%d.%d", BIO_snprintf(buf,sizeof buf,"%d.%d.%d.%d",
p[0],p[1],p[2],p[3]); p[0],p[1],p[2],p[3]);
if (data->param_hostname != NULL) if (data->param_hostname != NULL)
OPENSSL_free(data->param_hostname); OPENSSL_free(data->param_hostname);
@ -532,7 +532,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
{ {
char buf[DECIMAL_SIZE(int)+1]; char buf[DECIMAL_SIZE(int)+1];
sprintf(buf,"%d",*(int *)ptr); BIO_snprintf(buf,sizeof buf,"%d",*(int *)ptr);
if (data->param_port != NULL) if (data->param_port != NULL)
OPENSSL_free(data->param_port); OPENSSL_free(data->param_port);
data->param_port=BUF_strdup(buf); data->param_port=BUF_strdup(buf);

View File

@ -249,15 +249,15 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
if (num & BIO_FP_APPEND) if (num & BIO_FP_APPEND)
{ {
if (num & BIO_FP_READ) if (num & BIO_FP_READ)
strcpy(p,"a+"); BUF_strlcpy(p,"a+",sizeof p);
else strcpy(p,"a"); else BUF_strlcpy(p,"a",sizeof p);
} }
else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE)) else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE))
strcpy(p,"r+"); BUF_strlcpy(p,"r+",sizeof p);
else if (num & BIO_FP_WRITE) else if (num & BIO_FP_WRITE)
strcpy(p,"w"); BUF_strlcpy(p,"w",sizeof p);
else if (num & BIO_FP_READ) else if (num & BIO_FP_READ)
strcpy(p,"r"); BUF_strlcpy(p,"r",sizeof p);
else else
{ {
BIOerr(BIO_F_FILE_CTRL,BIO_R_BAD_FOPEN_MODE); BIOerr(BIO_F_FILE_CTRL,BIO_R_BAD_FOPEN_MODE);

View File

@ -124,7 +124,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -145,11 +145,11 @@ char *BN_options(void)
{ {
init++; init++;
#ifdef BN_LLONG #ifdef BN_LLONG
sprintf(data,"bn(%d,%d)",(int)sizeof(BN_ULLONG)*8, BIO_snprintf(data,sizeof data,"bn(%d,%d)",
(int)sizeof(BN_ULONG)*8); (int)sizeof(BN_ULLONG)*8,(int)sizeof(BN_ULONG)*8);
#else #else
sprintf(data,"bn(%d,%d)",(int)sizeof(BN_ULONG)*8, BIO_snprintf(data,sizeof data,"bn(%d,%d)",
(int)sizeof(BN_ULONG)*8); (int)sizeof(BN_ULONG)*8,(int)sizeof(BN_ULONG)*8);
#endif #endif
} }
return(data); return(data);

View File

@ -119,6 +119,7 @@ char *BN_bn2dec(const BIGNUM *a)
} }
if ((t=BN_dup(a)) == NULL) goto err; if ((t=BN_dup(a)) == NULL) goto err;
#define BUF_REMAIN (num+3 - (size_t)(p - buf))
p=buf; p=buf;
lp=bn_data; lp=bn_data;
if (t->neg) *(p++)='-'; if (t->neg) *(p++)='-';
@ -139,12 +140,12 @@ char *BN_bn2dec(const BIGNUM *a)
/* We now have a series of blocks, BN_DEC_NUM chars /* We now have a series of blocks, BN_DEC_NUM chars
* in length, where the last one needs truncation. * in length, where the last one needs truncation.
* The blocks need to be reversed in order. */ * The blocks need to be reversed in order. */
sprintf(p,BN_DEC_FMT1,*lp); BIO_snprintf(p,BUF_REMAIN,BN_DEC_FMT1,*lp);
while (*p) p++; while (*p) p++;
while (lp != bn_data) while (lp != bn_data)
{ {
lp--; lp--;
sprintf(p,BN_DEC_FMT2,*lp); BIO_snprintf(p,BUF_REMAIN,BN_DEC_FMT2,*lp);
while (*p) p++; while (*p) p++;
} }
} }

View File

@ -47,7 +47,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -71,7 +71,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -50,7 +50,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -50,7 +50,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -235,7 +235,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE); CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
strcpy(section,"default"); BUF_strlcpy(section,"default",10);
if (_CONF_new_data(conf) == 0) if (_CONF_new_data(conf) == 0)
{ {
@ -392,7 +392,7 @@ again:
ERR_R_MALLOC_FAILURE); ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
strcpy(v->name,pname); BUF_strlcpy(v->name,pname,strlen(pname)+1);
if (!str_copy(conf,psection,&(v->value),start)) goto err; if (!str_copy(conf,psection,&(v->value),start)) goto err;
if (strcmp(psection,section) != 0) if (strcmp(psection,section) != 0)
@ -447,7 +447,7 @@ err:
if (buff != NULL) BUF_MEM_free(buff); if (buff != NULL) BUF_MEM_free(buff);
if (section != NULL) OPENSSL_free(section); if (section != NULL) OPENSSL_free(section);
if (line != NULL) *line=eline; if (line != NULL) *line=eline;
sprintf(btmp,"%ld",eline); BIO_snprintf(btmp,sizeof btmp,"%ld",eline);
ERR_add_error_data(2,"line ",btmp); ERR_add_error_data(2,"line ",btmp);
if ((h != conf->data) && (conf->data != NULL)) if ((h != conf->data) && (conf->data != NULL))
{ {

View File

@ -232,7 +232,7 @@ static int module_run(const CONF *cnf, char *name, char *value,
{ {
char rcode[DECIMAL_SIZE(ret)+1]; char rcode[DECIMAL_SIZE(ret)+1];
CONFerr(CONF_F_CONF_MODULES_LOAD, CONF_R_MODULE_INITIALIZATION_ERROR); CONFerr(CONF_F_CONF_MODULES_LOAD, CONF_R_MODULE_INITIALIZATION_ERROR);
sprintf(rcode, "%-8d", ret); BIO_snprintf(rcode, sizeof rcode, "%-8d", ret);
ERR_add_error_data(6, "module=", name, ", value=", value, ", retcode=", rcode); ERR_add_error_data(6, "module=", name, ", value=", value, ", retcode=", rcode);
} }
} }
@ -561,11 +561,11 @@ char *CONF_get1_default_config_file(void)
if (!file) if (!file)
return NULL; return NULL;
strcpy(file,X509_get_default_cert_area()); BUF_strlcpy(file,X509_get_default_cert_area(),len + 1);
#ifndef OPENSSL_SYS_VMS #ifndef OPENSSL_SYS_VMS
strcat(file,"/"); BUF_strlcat(file,"/",len + 1);
#endif #endif
strcat(file,OPENSSL_CONF); BUF_strlcat(file,OPENSSL_CONF,len + 1);
return file; return file;
} }

View File

@ -61,7 +61,9 @@
#include "cryptlib.h" #include "cryptlib.h"
#include <openssl/crypto.h> #include <openssl/crypto.h>
#ifndef NO_WINDOWS_BRAINDEATH
#include "buildinf.h" #include "buildinf.h"
#endif
const char *SSLeay_version(int t) const char *SSLeay_version(int t)
{ {
@ -72,7 +74,7 @@ const char *SSLeay_version(int t)
#ifdef DATE #ifdef DATE
static char buf[sizeof(DATE)+11]; static char buf[sizeof(DATE)+11];
sprintf(buf,"built on: %s",DATE); BIO_snprintf(buf,sizeof buf,"built on: %s",DATE);
return(buf); return(buf);
#else #else
return("built on: date not available"); return("built on: date not available");
@ -83,7 +85,7 @@ const char *SSLeay_version(int t)
#ifdef CFLAGS #ifdef CFLAGS
static char buf[sizeof(CFLAGS)+11]; static char buf[sizeof(CFLAGS)+11];
sprintf(buf,"compiler: %s",CFLAGS); BIO_snprintf(buf,sizeof buf,"compiler: %s",CFLAGS);
return(buf); return(buf);
#else #else
return("compiler: information not available"); return("compiler: information not available");
@ -94,7 +96,7 @@ const char *SSLeay_version(int t)
#ifdef PLATFORM #ifdef PLATFORM
static char buf[sizeof(PLATFORM)+11]; static char buf[sizeof(PLATFORM)+11];
sprintf(buf,"platform: %s", PLATFORM); BIO_snprintf(buf,sizeof buf,"platform: %s", PLATFORM);
return(buf); return(buf);
#else #else
return("platform: information not available"); return("platform: information not available");

View File

@ -97,7 +97,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -60,6 +60,7 @@
#include "des_ver.h" #include "des_ver.h"
#include "spr.h" #include "spr.h"
#include <openssl/opensslv.h> #include <openssl/opensslv.h>
#include <openssl/bio.h>
OPENSSL_GLOBAL const char *libdes_version="libdes" OPENSSL_VERSION_PTEXT; OPENSSL_GLOBAL const char *libdes_version="libdes" OPENSSL_VERSION_PTEXT;
OPENSSL_GLOBAL const char *DES_version="DES" OPENSSL_VERSION_PTEXT; OPENSSL_GLOBAL const char *DES_version="DES" OPENSSL_VERSION_PTEXT;
@ -97,7 +98,8 @@ const char *DES_options(void)
size="int"; size="int";
else else
size="long"; size="long";
sprintf(buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,size); BIO_snprintf(buf,sizeof buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,
size);
init=0; init=0;
} }
return(buf); return(buf);

View File

@ -47,7 +47,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -49,7 +49,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -49,7 +49,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -383,7 +383,7 @@ int DSO_set_filename(DSO *dso, const char *filename)
DSOerr(DSO_F_DSO_SET_FILENAME,ERR_R_MALLOC_FAILURE); DSOerr(DSO_F_DSO_SET_FILENAME,ERR_R_MALLOC_FAILURE);
return(0); return(0);
} }
strcpy(copied, filename); BUF_strlcpy(copied, filename, strlen(filename) + 1);
if(dso->filename) if(dso->filename)
OPENSSL_free(dso->filename); OPENSSL_free(dso->filename);
dso->filename = copied; dso->filename = copied;
@ -422,7 +422,7 @@ char *DSO_convert_filename(DSO *dso, const char *filename)
ERR_R_MALLOC_FAILURE); ERR_R_MALLOC_FAILURE);
return(NULL); return(NULL);
} }
strcpy(result, filename); BUF_strlcpy(result, filename, strlen(filename) + 1);
} }
return(result); return(result);
} }

View File

@ -50,7 +50,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -57,7 +57,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -160,15 +160,19 @@ static int int_ctrl_helper(ENGINE *e, int cmd, long i, void *p, void (*f)())
case ENGINE_CTRL_GET_NAME_LEN_FROM_CMD: case ENGINE_CTRL_GET_NAME_LEN_FROM_CMD:
return strlen(e->cmd_defns[idx].cmd_name); return strlen(e->cmd_defns[idx].cmd_name);
case ENGINE_CTRL_GET_NAME_FROM_CMD: case ENGINE_CTRL_GET_NAME_FROM_CMD:
return sprintf(s, "%s", e->cmd_defns[idx].cmd_name); return BIO_snprintf(s,strlen(e->cmd_defns[idx].cmd_name) + 1,
"%s", e->cmd_defns[idx].cmd_name);
case ENGINE_CTRL_GET_DESC_LEN_FROM_CMD: case ENGINE_CTRL_GET_DESC_LEN_FROM_CMD:
if(e->cmd_defns[idx].cmd_desc) if(e->cmd_defns[idx].cmd_desc)
return strlen(e->cmd_defns[idx].cmd_desc); return strlen(e->cmd_defns[idx].cmd_desc);
return strlen(int_no_description); return strlen(int_no_description);
case ENGINE_CTRL_GET_DESC_FROM_CMD: case ENGINE_CTRL_GET_DESC_FROM_CMD:
if(e->cmd_defns[idx].cmd_desc) if(e->cmd_defns[idx].cmd_desc)
return sprintf(s, "%s", e->cmd_defns[idx].cmd_desc); return BIO_snprintf(s,
return sprintf(s, "%s", int_no_description); strlen(e->cmd_defns[idx].cmd_desc) + 1,
"%s", e->cmd_defns[idx].cmd_desc);
return BIO_snprintf(s, strlen(int_no_description) + 1,"%s",
int_no_description);
case ENGINE_CTRL_GET_CMD_FLAGS: case ENGINE_CTRL_GET_CMD_FLAGS:
return e->cmd_defns[idx].cmd_flags; return e->cmd_defns[idx].cmd_flags;
} }

View File

@ -12,9 +12,6 @@
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -878,7 +875,6 @@ cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
goto err; goto err;
} }
printf("bar\n");
memset(&kop, 0, sizeof kop); memset(&kop, 0, sizeof kop);
kop.crk_op = CRK_DSA_SIGN; kop.crk_op = CRK_DSA_SIGN;

View File

@ -47,7 +47,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -1065,7 +1065,7 @@ void ERR_add_error_data(int num, ...)
else else
str=p; str=p;
} }
strcat(str,a); BUF_strlcat(str,a,s+1);
} }
} }
ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING); ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING);

View File

@ -67,7 +67,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
cp $(TESTDATA) ../../test cp $(TESTDATA) ../../test

View File

@ -102,7 +102,7 @@
*) digest is initialized with random seed instead of *) digest is initialized with random seed instead of
standardized one. standardized one.
*) same seed is written to ouput *) same seed is written to output
*) well-known text is then hashed and the output *) well-known text is then hashed and the output
of the digest is also written to output. of the digest is also written to output.

View File

@ -87,7 +87,7 @@ int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
if (i == -1) { if (i == -1) {
char obj_tmp[80]; char obj_tmp[80];
EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM); EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM);
if (!pbe_obj) strcpy (obj_tmp, "NULL"); if (!pbe_obj) BUF_strlcpy (obj_tmp, "NULL", sizeof obj_tmp);
else i2t_ASN1_OBJECT(obj_tmp, sizeof obj_tmp, pbe_obj); else i2t_ASN1_OBJECT(obj_tmp, sizeof obj_tmp, pbe_obj);
ERR_add_error_data(2, "TYPE=", obj_tmp); ERR_add_error_data(2, "TYPE=", obj_tmp);
return 0; return 0;

View File

@ -210,7 +210,7 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
#endif #endif
default: default:
EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM); EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM);
if (!a->algorithm) strcpy (obj_tmp, "NULL"); if (!a->algorithm) BUF_strlcpy (obj_tmp, "NULL", sizeof obj_tmp);
else i2t_ASN1_OBJECT(obj_tmp, 80, a->algorithm); else i2t_ASN1_OBJECT(obj_tmp, 80, a->algorithm);
ERR_add_error_data(2, "TYPE=", obj_tmp); ERR_add_error_data(2, "TYPE=", obj_tmp);
EVP_PKEY_free (pkey); EVP_PKEY_free (pkey);

View File

@ -47,7 +47,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -47,7 +47,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -48,7 +48,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile ; @sh $(TOP)/util/point.sh Makefile.ssl Makefile ;
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -47,7 +47,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -47,7 +47,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -48,7 +48,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -84,7 +84,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -47,7 +47,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -597,6 +597,8 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
struct tm *lcl = NULL; struct tm *lcl = NULL;
unsigned long ti; unsigned long ti;
#define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
if(m->addr == (char *)l->bio) if(m->addr == (char *)l->bio)
return; return;
@ -604,22 +606,22 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
{ {
lcl = localtime(&m->time); lcl = localtime(&m->time);
sprintf(bufp, "[%02d:%02d:%02d] ", BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
lcl->tm_hour,lcl->tm_min,lcl->tm_sec); lcl->tm_hour,lcl->tm_min,lcl->tm_sec);
bufp += strlen(bufp); bufp += strlen(bufp);
} }
sprintf(bufp, "%5lu file=%s, line=%d, ", BIO_snprintf(bufp, BUF_REMAIN, "%5lu file=%s, line=%d, ",
m->order,m->file,m->line); m->order,m->file,m->line);
bufp += strlen(bufp); bufp += strlen(bufp);
if (options & V_CRYPTO_MDEBUG_THREAD) if (options & V_CRYPTO_MDEBUG_THREAD)
{ {
sprintf(bufp, "thread=%lu, ", m->thread); BIO_snprintf(bufp, BUF_REMAIN, "thread=%lu, ", m->thread);
bufp += strlen(bufp); bufp += strlen(bufp);
} }
sprintf(bufp, "number=%d, address=%08lX\n", BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%08lX\n",
m->num,(unsigned long)m->addr); m->num,(unsigned long)m->addr);
bufp += strlen(bufp); bufp += strlen(bufp);
@ -641,7 +643,7 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
ami_cnt++; ami_cnt++;
memset(buf,'>',ami_cnt); memset(buf,'>',ami_cnt);
sprintf(buf + ami_cnt, BIO_snprintf(buf + ami_cnt, sizeof buf - ami_cnt,
" thread=%lu, file=%s, line=%d, info=\"", " thread=%lu, file=%s, line=%d, info=\"",
amip->thread, amip->file, amip->line); amip->thread, amip->file, amip->line);
buf_len=strlen(buf); buf_len=strlen(buf);
@ -653,10 +655,11 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
} }
else else
{ {
strcpy(buf + buf_len, amip->info); BUF_strlcpy(buf + buf_len, amip->info,
sizeof buf - buf_len);
buf_len = strlen(buf); buf_len = strlen(buf);
} }
sprintf(buf + buf_len, "\"\n"); BIO_snprintf(buf + buf_len, sizeof buf - buf_len, "\"\n");
BIO_puts(l->bio,buf); BIO_puts(l->bio,buf);

View File

@ -55,7 +55,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -462,7 +462,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
if (i > 2) i=2; if (i > 2) i=2;
l-=(long)(i*40); l-=(long)(i*40);
sprintf(tbuf,"%d.%lu",i,l); BIO_snprintf(tbuf,sizeof tbuf,"%d.%lu",i,l);
i=strlen(tbuf); i=strlen(tbuf);
BUF_strlcpy(buf,tbuf,buf_len); BUF_strlcpy(buf,tbuf,buf_len);
buf_len-=i; buf_len-=i;
@ -473,7 +473,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
for (; idx<len; idx++) { for (; idx<len; idx++) {
l|=p[idx]&0x7f; l|=p[idx]&0x7f;
if (!(p[idx] & 0x80)) { if (!(p[idx] & 0x80)) {
sprintf(tbuf,".%lu",l); BIO_snprintf(tbuf,sizeof tbuf,".%lu",l);
i=strlen(tbuf); i=strlen(tbuf);
if (buf_len > 0) if (buf_len > 0)
BUF_strlcpy(buf,tbuf,buf_len); BUF_strlcpy(buf,tbuf,buf_len);

View File

@ -1,5 +1,9 @@
#!/usr/local/bin/perl #!/usr/local/bin/perl
# fixes bug in floating point emulation on sparc64 when
# this script produces off-by-one output on sparc64
use integer;
sub obj_cmp sub obj_cmp
{ {
local(@a,@b,$_,$r); local(@a,@b,$_,$r);

View File

@ -50,7 +50,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile ; @sh $(TOP)/util/point.sh Makefile.ssl Makefile ;
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -50,7 +50,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: $(EXHEADER) links: $(EXHEADER)
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -131,9 +131,9 @@ void PEM_proc_type(char *buf, int type)
else else
str="BAD-TYPE"; str="BAD-TYPE";
strcat(buf,"Proc-Type: 4,"); BUF_strlcat(buf,"Proc-Type: 4,",PEM_BUFSIZE);
strcat(buf,str); BUF_strlcat(buf,str,PEM_BUFSIZE);
strcat(buf,"\n"); BUF_strlcat(buf,"\n",PEM_BUFSIZE);
} }
void PEM_dek_info(char *buf, const char *type, int len, char *str) void 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)
long i; long i;
int j; int j;
strcat(buf,"DEK-Info: "); BUF_strlcat(buf,"DEK-Info: ",PEM_BUFSIZE);
strcat(buf,type); BUF_strlcat(buf,type,PEM_BUFSIZE);
strcat(buf,","); BUF_strlcat(buf,",",PEM_BUFSIZE);
j=strlen(buf); j=strlen(buf);
if (j + (len * 2) + 1 > PEM_BUFSIZE)
return;
for (i=0; i<len; i++) for (i=0; i<len; i++)
{ {
buf[j+i*2] =map[(str[i]>>4)&0x0f]; buf[j+i*2] =map[(str[i]>>4)&0x0f];

View File

@ -53,7 +53,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -68,7 +68,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -49,7 +49,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -56,6 +56,7 @@
#include <openssl/e_os2.h> #include <openssl/e_os2.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/buffer.h>
/* /*
* Query the EGD <URL: http://www.lothar.com/tech/crypto/>. * Query the EGD <URL: http://www.lothar.com/tech/crypto/>.
@ -145,7 +146,7 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
if (strlen(path) >= sizeof(addr.sun_path)) if (strlen(path) >= sizeof(addr.sun_path))
return (-1); return (-1);
strcpy(addr.sun_path,path); BUF_strlcpy(addr.sun_path,path,sizeof addr.sun_path);
len = offsetof(struct sockaddr_un, sun_path) + strlen(path); len = offsetof(struct sockaddr_un, sun_path) + strlen(path);
fd = socket(AF_UNIX, SOCK_STREAM, 0); fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == -1) return (-1); if (fd == -1) return (-1);

View File

@ -124,6 +124,24 @@
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#ifdef __OpenBSD__
int RAND_poll(void)
{
u_int32_t rnd = 0, i;
unsigned char buf[ENTROPY_NEEDED];
for (i = 0; i < sizeof(buf); i++) {
if (i % 4 == 0)
rnd = arc4random();
buf[i] = rnd;
rnd >>= 8;
}
RAND_add(buf, sizeof(buf), ENTROPY_NEEDED);
memset(buf, 0, sizeof(buf));
return 1;
}
#else
int RAND_poll(void) int RAND_poll(void)
{ {
unsigned long l; unsigned long l;
@ -235,6 +253,7 @@ int RAND_poll(void)
#endif #endif
} }
#endif
#endif #endif
#if defined(OPENSSL_SYS_VXWORKS) #if defined(OPENSSL_SYS_VXWORKS)

View File

@ -646,7 +646,7 @@ static void readtimer(void)
* Created 960901 by Gertjan van Oosten, gertjan@West.NL, West Consulting B.V. * Created 960901 by Gertjan van Oosten, gertjan@West.NL, West Consulting B.V.
* *
* Code adapted from * Code adapted from
* <URL:http://www.microsoft.com/kb/developr/win_dk/q97193.htm>; * <URL:http://support.microsoft.com/default.aspx?scid=kb;[LN];97193>;
* the original copyright message is: * the original copyright message is:
* *
* (C) Copyright Microsoft Corp. 1993. All rights reserved. * (C) Copyright Microsoft Corp. 1993. All rights reserved.

View File

@ -56,6 +56,9 @@
* [including the GNU Public Licence.] * [including the GNU Public Licence.]
*/ */
/* We need to define this to get macros like S_IFBLK and S_IFCHR */
#define _XOPEN_SOURCE 1
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -64,6 +67,7 @@
#include "e_os.h" #include "e_os.h"
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/buffer.h>
#ifdef OPENSSL_SYS_VMS #ifdef OPENSSL_SYS_VMS
#include <unixio.h> #include <unixio.h>
@ -106,6 +110,14 @@ int RAND_load_file(const char *file, long bytes)
in=fopen(file,"rb"); in=fopen(file,"rb");
if (in == NULL) goto err; if (in == NULL) goto err;
if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
/* this file is a device. we don't want read an infinite number
* of bytes from a random device, nor do we want to use buffered
* I/O because we will waste system entropy.
*/
bytes = (bytes == -1) ? 2048 : bytes; /* ok, is 2048 enough? */
setvbuf(in, NULL, _IONBF, 0); /* don't do buffered reads */
}
for (;;) for (;;)
{ {
if (bytes > 0) if (bytes > 0)
@ -135,6 +147,19 @@ int RAND_write_file(const char *file)
int i,ret=0,rand_err=0; int i,ret=0,rand_err=0;
FILE *out = NULL; FILE *out = NULL;
int n; int n;
struct stat sb;
i=stat(file,&sb);
if (i != -1) {
if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
/* this file is a device. we don't write back to it.
* we "succeed" on the assumption this is some sort
* of random device. Otherwise attempting to write to
* and chmod the device causes problems.
*/
return(1);
}
}
#if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32) #if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32)
/* For some reason Win32 can't write to files created this way */ /* For some reason Win32 can't write to files created this way */
@ -197,16 +222,17 @@ err:
const char *RAND_file_name(char *buf, size_t size) const char *RAND_file_name(char *buf, size_t size)
{ {
char *s=NULL; char *s=NULL;
char *ret=NULL; int ok = 0;
#ifdef __OpenBSD__
struct stat sb;
#endif
if (OPENSSL_issetugid() == 0) if (OPENSSL_issetugid() == 0)
s=getenv("RANDFILE"); s=getenv("RANDFILE");
if (s != NULL) if (s != NULL && *s && strlen(s) + 1 < size)
{ {
if(strlen(s) >= size) if (BUF_strlcpy(buf,s,size) >= size)
return NULL; return NULL;
strcpy(buf,s);
ret=buf;
} }
else else
{ {
@ -218,17 +244,36 @@ const char *RAND_file_name(char *buf, size_t size)
s = DEFAULT_HOME; s = DEFAULT_HOME;
} }
#endif #endif
if (s != NULL && (strlen(s)+strlen(RFILE)+2 < size)) if (s && *s && strlen(s)+strlen(RFILE)+2 < size)
{ {
strcpy(buf,s); BUF_strlcpy(buf,s,size);
#ifndef OPENSSL_SYS_VMS #ifndef OPENSSL_SYS_VMS
strcat(buf,"/"); BUF_strlcat(buf,"/",size);
#endif #endif
strcat(buf,RFILE); BUF_strlcat(buf,RFILE,size);
ret=buf; ok = 1;
} }
else else
buf[0] = '\0'; /* no file name */ buf[0] = '\0'; /* no file name */
} }
return(ret);
#ifdef __OpenBSD__
/* given that all random loads just fail if the file can't be
* seen on a stat, we stat the file we're returning, if it
* fails, use /dev/arandom instead. this allows the user to
* use their own source for good random data, but defaults
* to something hopefully decent if that isn't available.
*/
if (!ok)
if (BUF_strlcpy(buf,"/dev/arandom",size) >= size) {
return(NULL);
}
if (stat(buf,&sb) == -1)
if (BUF_strlcpy(buf,"/dev/arandom",size) >= size) {
return(NULL);
}
#endif
return(buf);
} }

View File

@ -47,7 +47,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -71,7 +71,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -68,7 +68,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -66,7 +66,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -51,7 +51,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -66,7 +66,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -47,7 +47,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -243,7 +243,8 @@ bad:
goto end; goto end;
} }
if (cipher == NULL) cipher=getenv("SSL_CIPHER"); if (cipher == NULL && OPENSSL_issetugid() == 0)
cipher=getenv("SSL_CIPHER");
SSL_load_error_strings(); SSL_load_error_strings();
OpenSSL_add_ssl_algorithms(); OpenSSL_add_ssl_algorithms();

View File

@ -47,7 +47,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -51,7 +51,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -430,14 +430,14 @@ char *UI_construct_prompt(UI *ui, const char *object_desc,
len += sizeof(prompt3) - 1; len += sizeof(prompt3) - 1;
prompt = (char *)OPENSSL_malloc(len + 1); prompt = (char *)OPENSSL_malloc(len + 1);
strcpy(prompt, prompt1); BUF_strlcpy(prompt, prompt1, len + 1);
strcat(prompt, object_desc); BUF_strlcat(prompt, object_desc, len + 1);
if (object_name) if (object_name)
{ {
strcat(prompt, prompt2); BUF_strlcat(prompt, prompt2, len + 1);
strcat(prompt, object_name); BUF_strlcat(prompt, object_name, len + 1);
} }
strcat(prompt, prompt3); BUF_strlcat(prompt, prompt3, len + 1);
} }
return prompt; return prompt;
} }
@ -865,7 +865,8 @@ int UI_set_result(UI *ui, UI_STRING *uis, const char *result)
return -1; return -1;
} }
strcpy(uis->result_buf, result); BUF_strlcpy(uis->result_buf, result,
uis->_.string_data.result_maxsize + 1);
break; break;
case UIT_BOOLEAN: case UIT_BOOLEAN:
{ {

View File

@ -57,7 +57,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -302,8 +302,38 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
k=0; k=0;
for (;;) for (;;)
{ {
sprintf(b->data,"%s/%08lx.%s%d",ctx->dirs[i],h, char c = '/';
#ifdef OPENSSL_SYS_VMS
char c = ctx->dirs[i][strlen(ctx->dirs[i])-1];
if (c != ':' && c != '>' && c != ']')
{
/* If no separator is present, we assume the
directory specifier is a logical name, and
add a colon. We really should use better
VMS routines for merging things like this,
but this will do for now...
-- Richard Levitte */
c = ':';
}
else
{
c = '\0';
}
#endif
if (c == '\0')
{
/* This is special. When c == '\0', no
directory separator should be added. */
BIO_snprintf(b->data,b->max,
"%s%08lx.%s%d",ctx->dirs[i],h,
postfix,k); postfix,k);
}
else
{
BIO_snprintf(b->data,b->max,
"%s%c%08lx.%s%d",ctx->dirs[i],c,h,
postfix,k);
}
k++; k++;
if (stat(b->data,&st) < 0) if (stat(b->data,&st) < 0)
break; break;

View File

@ -148,7 +148,7 @@ const char *X509_verify_cert_error_string(long n)
return("unhandled critical extension"); return("unhandled critical extension");
default: default:
sprintf(buf,"error number %ld",n); BIO_snprintf(buf,sizeof buf,"error number %ld",n);
return(buf); return(buf);
} }
} }

View File

@ -53,7 +53,7 @@ files:
$(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links: links:
@$(TOP)/util/point.sh Makefile.ssl Makefile @sh $(TOP)/util/point.sh Makefile.ssl Makefile
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

View File

@ -137,7 +137,8 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,
X509V3_add_value("IP Address","<invalid>", &ret); X509V3_add_value("IP Address","<invalid>", &ret);
break; break;
} }
sprintf(oline, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); BIO_snprintf(oline, sizeof oline,
"%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
X509V3_add_value("IP Address",oline, &ret); X509V3_add_value("IP Address",oline, &ret);
break; break;

View File

@ -105,7 +105,7 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method
STACK_OF(CONF_VALUE) *ret) STACK_OF(CONF_VALUE) *ret)
{ {
ACCESS_DESCRIPTION *desc; ACCESS_DESCRIPTION *desc;
int i; int i,nlen;
char objtmp[80], *ntmp; char objtmp[80], *ntmp;
CONF_VALUE *vtmp; CONF_VALUE *vtmp;
for(i = 0; i < sk_ACCESS_DESCRIPTION_num(ainfo); i++) { for(i = 0; i < sk_ACCESS_DESCRIPTION_num(ainfo); i++) {
@ -114,15 +114,16 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method
if(!ret) break; if(!ret) break;
vtmp = sk_CONF_VALUE_value(ret, i); vtmp = sk_CONF_VALUE_value(ret, i);
i2t_ASN1_OBJECT(objtmp, sizeof objtmp, desc->method); i2t_ASN1_OBJECT(objtmp, sizeof objtmp, desc->method);
ntmp = OPENSSL_malloc(strlen(objtmp) + strlen(vtmp->name) + 5); nlen = strlen(objtmp) + strlen(vtmp->name) + 5;
ntmp = OPENSSL_malloc(nlen);
if(!ntmp) { if(!ntmp) {
X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS, X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS,
ERR_R_MALLOC_FAILURE); ERR_R_MALLOC_FAILURE);
return NULL; return NULL;
} }
strcpy(ntmp, objtmp); BUF_strlcpy(ntmp, objtmp, nlen);
strcat(ntmp, " - "); BUF_strlcat(ntmp, " - ", nlen);
strcat(ntmp, vtmp->name); BUF_strlcat(ntmp, vtmp->name, nlen);
OPENSSL_free(vtmp->name); OPENSSL_free(vtmp->name);
vtmp->name = ntmp; vtmp->name = ntmp;

View File

@ -329,7 +329,8 @@ L<passwd(1)|passwd(1)>,
L<pkcs12(1)|pkcs12(1)>, L<pkcs7(1)|pkcs7(1)>, L<pkcs8(1)|pkcs8(1)>, L<pkcs12(1)|pkcs12(1)>, L<pkcs7(1)|pkcs7(1)>, L<pkcs8(1)|pkcs8(1)>,
L<rand(1)|rand(1)>, L<req(1)|req(1)>, L<rsa(1)|rsa(1)>, L<rand(1)|rand(1)>, L<req(1)|req(1)>, L<rsa(1)|rsa(1)>,
L<rsautl(1)|rsautl(1)>, L<s_client(1)|s_client(1)>, L<rsautl(1)|rsautl(1)>, L<s_client(1)|s_client(1)>,
L<s_server(1)|s_server(1)>, L<smime(1)|smime(1)>, L<spkac(1)|spkac(1)>, L<s_server(1)|s_server(1)>, L<s_time(1)|s_time(1)>,
L<smime(1)|smime(1)>, L<spkac(1)|spkac(1)>,
L<verify(1)|verify(1)>, L<version(1)|version(1)>, L<x509(1)|x509(1)>, L<verify(1)|verify(1)>, L<version(1)|version(1)>, L<x509(1)|x509(1)>,
L<crypto(3)|crypto(3)>, L<ssl(3)|ssl(3)> L<crypto(3)|crypto(3)>, L<ssl(3)|ssl(3)>

View File

@ -8,7 +8,7 @@ s_client - SSL/TLS client program
=head1 SYNOPSIS =head1 SYNOPSIS
B<openssl> B<s_client> B<openssl> B<s_client>
[B<-connect> host:port>] [B<-connect host:port>]
[B<-verify depth>] [B<-verify depth>]
[B<-cert filename>] [B<-cert filename>]
[B<-key filename>] [B<-key filename>]
@ -208,7 +208,7 @@ then an HTTP command can be given such as "GET /" to retrieve a web page.
If the handshake fails then there are several possible causes, if it is If the handshake fails then there are several possible causes, if it is
nothing obvious like no client certificate then the B<-bugs>, B<-ssl2>, nothing obvious like no client certificate then the B<-bugs>, B<-ssl2>,
B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1> can be tried B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1> options can be tried
in case it is a buggy server. In particular you should play with these in case it is a buggy server. In particular you should play with these
options B<before> submitting a bug report to an OpenSSL mailing list. options B<before> submitting a bug report to an OpenSSL mailing list.
@ -219,7 +219,7 @@ the clients certificate authority in its "acceptable CA list" when it
requests a certificate. By using B<s_client> the CA list can be viewed requests a certificate. By using B<s_client> the CA list can be viewed
and checked. However some servers only request client authentication and checked. However some servers only request client authentication
after a specific URL is requested. To obtain the list in this case it after a specific URL is requested. To obtain the list in this case it
is necessary to use the B<-prexit> command and send an HTTP request is necessary to use the B<-prexit> option and send an HTTP request
for an appropriate page. for an appropriate page.
If a certificate is specified on the command line using the B<-cert> If a certificate is specified on the command line using the B<-cert>

View File

@ -36,7 +36,7 @@ None of the functions return a value.
=head1 NOTES =head1 NOTES
A typical application will will call OpenSSL_add_all_algorithms() initially and A typical application will call OpenSSL_add_all_algorithms() initially and
EVP_cleanup() before exiting. EVP_cleanup() before exiting.
An application does not need to add algorithms to use them explicitly, for example An application does not need to add algorithms to use them explicitly, for example

View File

@ -44,6 +44,6 @@ L<dh(3)|dh(3)>, L<dsa(3)|dsa(3)>, L<rsa(3)|rsa(3)>, L<BN_bn2bin(3)|BN_bn2bin(3)>
RSA_print(), RSA_print_fp(), DSA_print(), DSA_print_fp(), DH_print(), RSA_print(), RSA_print_fp(), DSA_print(), DSA_print_fp(), DH_print(),
DH_print_fp() are available in all versions of SSLeay and OpenSSL. DH_print_fp() are available in all versions of SSLeay and OpenSSL.
DSAparams_print() and DSAparams_print_pf() were added in SSLeay 0.8. DSAparams_print() and DSAparams_print_fp() were added in SSLeay 0.8.
=cut =cut

Some files were not shown because too many files have changed in this diff Show More