From: Richard Levitte Date: Sun, 28 Sep 2003 07:11:33 +0000 (+0000) Subject: Uhmm, It seem to have forgotten one file when I committed the MSDOS X-Git-Tag: BEN_FIPS_TEST_4^2~11^2~97 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f3ba9428f29dd424267f75fa2de7d0fe513a6c9;p=openssl Uhmm, It seem to have forgotten one file when I committed the MSDOS change yesterday. PR: 669 --- diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c index a66600c1a3..1f9bd3312a 100644 --- a/crypto/bio/bss_file.c +++ b/crypto/bio/bss_file.c @@ -213,12 +213,29 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr) b->shutdown=(int)num&BIO_CLOSE; b->ptr=(char *)ptr; b->init=1; -#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) +#if defined(OPENSSL_SYS_WINDOWS) + if (num & BIO_FP_TEXT) + _setmode(fd,_O_TEXT); + else + _setmode(fd,_O_BINARY); +#elif defined(OPENSSL_SYS_MSDOS) + { + int fd = fileno((FILE*)ptr); /* Set correct text/binary mode */ if (num & BIO_FP_TEXT) - _setmode(fileno((FILE *)ptr),_O_TEXT); + _setmode(fd,_O_TEXT); + /* Dangerous to set stdin/stdout to raw (unless redirected) */ else - _setmode(fileno((FILE *)ptr),_O_BINARY); + { + if (fd == STDIN_FILENO || fd == STDOUT_FILENO) + { + if (isatty(fd) <= 0) + _setmode(fd,_O_BINARY); + } + else + _setmode(fd,_O_BINARY); + } + } #elif defined(OPENSSL_SYS_OS2) if (num & BIO_FP_TEXT) setmode(fileno((FILE *)ptr), O_TEXT);