Uhmm, It seem to have forgotten one file when I committed the MSDOS
authorRichard Levitte <levitte@openssl.org>
Sun, 28 Sep 2003 07:11:37 +0000 (07:11 +0000)
committerRichard Levitte <levitte@openssl.org>
Sun, 28 Sep 2003 07:11:37 +0000 (07:11 +0000)
change yesterday.
PR: 669

crypto/bio/bss_file.c

index a66600c1a34c2ff0812b124da214570080d4cfd9..1f9bd3312af7e4c731a1bdb400c6dba43a589edb 100644 (file)
@@ -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);