Make sure fd is defined where it should.
authorRichard Levitte <levitte@openssl.org>
Sun, 21 Mar 2004 22:36:30 +0000 (22:36 +0000)
committerRichard Levitte <levitte@openssl.org>
Sun, 21 Mar 2004 22:36:30 +0000 (22:36 +0000)
PR: 849

crypto/bio/bss_file.c

index 9cdf159f82f827c5f2ed22a7eb47fdd1bbda6fd6..554474733fbcef6c5f6a8413ea1b20b560843158 100644 (file)
@@ -213,14 +213,14 @@ 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;
+               {
+               int fd = fileno((FILE*)ptr);
 #if defined(OPENSSL_SYS_WINDOWS)
                if (num & BIO_FP_TEXT)
-                       _setmode(fileno((FILE *)ptr),_O_TEXT);
+                       _setmode(fd,_O_TEXT);
                else
-                       _setmode(fileno((FILE *)ptr),_O_BINARY);
+                       _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(fd,_O_TEXT);
@@ -235,13 +235,13 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
                        else
                                _setmode(fd,_O_BINARY);
                        }
-               }
 #elif defined(OPENSSL_SYS_OS2)
                if (num & BIO_FP_TEXT)
-                       setmode(fileno((FILE *)ptr), O_TEXT);
+                       setmode(fd, O_TEXT);
                else
-                       setmode(fileno((FILE *)ptr), O_BINARY);
+                       setmode(fd, O_BINARY);
 #endif
+               }
                break;
        case BIO_C_SET_FILENAME:
                file_free(b);