Solar Designer wrote:
> Thank you for working on this!
OK, try the attached patch...
Cheers,
Ben.
--
http://www.apache-ssl.org/ben.html http://www.thebunker.net/
"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff
Index: apps/dgst.c
===================================================================
RCS file: /e/openssl/cvs/openssl/apps/dgst.c,v
retrieving revision 1.23.2.2
diff -u -r1.23.2.2 dgst.c
--- apps/dgst.c 2002/04/06 18:59:57 1.23.2.2
+++ apps/dgst.c 2002/04/24 14:39:06
@@ -73,8 +73,8 @@
#undef PROG
#define PROG dgst_main
-void do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
- EVP_PKEY *key, unsigned char *sigin, int siglen);
+int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
+ EVP_PKEY *key, unsigned char *sigin, int siglen, const char *title);
int MAIN(int, char **);
@@ -319,22 +319,33 @@
if (argc == 0)
{
BIO_set_fp(in,stdin,BIO_NOCLOSE);
- do_fp(out, buf,inp,separator, out_bin, sigkey, sigbuf, siglen);
+ do_fp(out, buf,inp,separator, out_bin, sigkey, sigbuf, siglen,
+ "");
}
else
{
name=OBJ_nid2sn(md->type);
for (i=0; i<argc; i++)
{
+ char *tmp,*tofree=NULL;
+
if (BIO_read_filename(in,argv[i]) <= 0)
{
perror(argv[i]);
err++;
continue;
+ }
+ if(!out_bin)
+ {
+
+tmp=tofree=OPENSSL_malloc(strlen(name)+strlen(argv[i])+5);
+ sprintf(tmp,"%s(%s)= ",name,argv[i]);
}
- if(!out_bin) BIO_printf(out, "%s(%s)= ",name,argv[i]);
- do_fp(out, buf,inp,separator, out_bin, sigkey,
- sigbuf, siglen);
+ else
+ tmp="";
+ err=do_fp(out,buf,inp,separator,out_bin,sigkey,sigbuf,
+ siglen,tmp);
+ if(tofree)
+ OPENSSL_free(tofree);
(void)BIO_reset(bmd);
}
}
@@ -353,8 +364,8 @@
EXIT(err);
}
-void do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
- EVP_PKEY *key, unsigned char *sigin, int siglen)
+int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
+ EVP_PKEY *key, unsigned char *sigin, int siglen, const char *title)
{
int len;
int i;
@@ -362,21 +373,33 @@
for (;;)
{
i=BIO_read(bp,(char *)buf,BUFSIZE);
- if (i <= 0) break;
+ if(i < 0)
+ {
+ BIO_printf(bio_err, "Read Error\n");
+ ERR_print_errors(bio_err);
+ return 1;
+ }
+ if (i == 0) break;
}
if(sigin)
{
EVP_MD_CTX *ctx;
BIO_get_md_ctx(bp, &ctx);
i = EVP_VerifyFinal(ctx, sigin, (unsigned int)siglen, key);
- if(i > 0) BIO_printf(out, "Verified OK\n");
- else if(i == 0) BIO_printf(out, "Verification Failure\n");
+ if(i > 0)
+ BIO_printf(out, "Verified OK\n");
+ else if(i == 0)
+ {
+ BIO_printf(out, "Verification Failure\n");
+ return 1;
+ }
else
{
BIO_printf(bio_err, "Error Verifying Data\n");
ERR_print_errors(bio_err);
+ return 1;
}
- return;
+ return 0;
}
if(key)
{
@@ -386,7 +409,7 @@
{
BIO_printf(bio_err, "Error Signing Data\n");
ERR_print_errors(bio_err);
- return;
+ return 1;
}
}
else
@@ -395,6 +418,7 @@
if(binout) BIO_write(out, buf, len);
else
{
+ BIO_write(out,title,strlen(title));
for (i=0; i<len; i++)
{
if (sep && (i != 0))
@@ -403,5 +427,6 @@
}
BIO_printf(out, "\n");
}
+ return 0;
}
Index: crypto/bio/bss_file.c
===================================================================
RCS file: /e/openssl/cvs/openssl/crypto/bio/bss_file.c,v
retrieving revision 1.14
diff -u -r1.14 bss_file.c
--- crypto/bio/bss_file.c 2002/01/24 16:15:00 1.14
+++ crypto/bio/bss_file.c 2002/04/24 14:39:07
@@ -162,6 +162,8 @@
if (b->init && (out != NULL))
{
ret=fread(out,1,(int)outl,(FILE *)b->ptr);
+ if(ret == 0 && ferror((FILE *)b->ptr))
+ ret=-1;
}
return(ret);
}