Hello, this is an updated version of a patch I sent on May 22. I didn't get any response that time - please let me know if you have issues with the bugfix, or if I should be contacting someone else about it. It's a minor bug but it breaks the application I was using it for.
The "enc" application provides a "-bufsize number" option to control the I/O buffer size, but this does not work correctly for use in pipelines since stdin and stdout are buffered by default on most OSes. For example, on my Linux system it calls fread() to request 80 bytes, but this results in a "read" syscall requesting 4096 bytes to fill the stdin buffer, which will block and wait if this much data isn't available yet. A separate issue is that the code imposes a minimum of 80 byte block sizes for all I/O. Based on the comment this minimum should be used only when base64 encoding is active and not for binary I/O. The following patch uses the ANSI C setvbuf(3) function to turn off stdio buffering on stdin and stdout when the "-bufsize" argument is present, and also allows use of small block sizes when using binary I/O. This makes it possible to feed small chunks of data to "openssl enc" in a pipeline and immediately read back the corresponding chunks of encrypted output. -Klaus --- openssl-0.9.8a/apps/enc.c.orig 2006-07-27 18:37:05.000000000 -0500 +++ openssl-0.9.8a/apps/enc.c 2006-07-27 18:38:30.000000000 -0500 @@ -340,7 +340,7 @@ } /* It must be large enough for a base64 encoded line */ - if (n < 80) n=80; + if (base64 && n < 80) n=80; bsize=(int)n; if (verbose) BIO_printf(bio_err,"bufsize=%d\n",bsize); @@ -370,7 +370,11 @@ } if (inf == NULL) + { + if (bufsize != NULL) + setvbuf(stdin, (char *)NULL, _IONBF, 0); BIO_set_fp(in,stdin,BIO_NOCLOSE); + } else { if (BIO_read_filename(in,inf) <= 0) @@ -421,6 +425,8 @@ if (outf == NULL) { BIO_set_fp(out,stdout,BIO_NOCLOSE); + if (bufsize != NULL) + setvbuf(stdout, (char *)NULL, _IONBF, 0); #ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List openssl-dev@openssl.org Automated List Manager [EMAIL PROTECTED]