summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bio/bss_fd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bio/bss_fd.c')
-rw-r--r--src/lib/libcrypto/bio/bss_fd.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/src/lib/libcrypto/bio/bss_fd.c b/src/lib/libcrypto/bio/bss_fd.c
index 4c229bf641..5e3e187de6 100644
--- a/src/lib/libcrypto/bio/bss_fd.c
+++ b/src/lib/libcrypto/bio/bss_fd.c
@@ -60,19 +60,7 @@
60#include <errno.h> 60#include <errno.h>
61#define USE_SOCKETS 61#define USE_SOCKETS
62#include "cryptlib.h" 62#include "cryptlib.h"
63/* 63#include <openssl/bio.h>
64 * As for unconditional usage of "UPLINK" interface in this module.
65 * Trouble is that unlike Unix file descriptors [which are indexes
66 * in kernel-side per-process table], corresponding descriptors on
67 * platforms which require "UPLINK" interface seem to be indexes
68 * in a user-land, non-global table. Well, in fact they are indexes
69 * in stdio _iob[], and recall that _iob[] was the very reason why
70 * "UPLINK" interface was introduced in first place. But one way on
71 * another. Neither libcrypto or libssl use this BIO meaning that
72 * file descriptors can only be provided by application. Therefore
73 * "UPLINK" calls are due...
74 */
75#include "bio_lcl.h"
76 64
77static int fd_write(BIO *h, const char *buf, int num); 65static int fd_write(BIO *h, const char *buf, int num);
78static int fd_read(BIO *h, char *buf, int size); 66static int fd_read(BIO *h, char *buf, int size);
@@ -112,9 +100,9 @@ BIO *BIO_new_fd(int fd,int close_flag)
112static int fd_new(BIO *bi) 100static int fd_new(BIO *bi)
113 { 101 {
114 bi->init=0; 102 bi->init=0;
115 bi->num=-1; 103 bi->num=0;
116 bi->ptr=NULL; 104 bi->ptr=NULL;
117 bi->flags=BIO_FLAGS_UPLINK; /* essentially redundant */ 105 bi->flags=0;
118 return(1); 106 return(1);
119 } 107 }
120 108
@@ -125,10 +113,10 @@ static int fd_free(BIO *a)
125 { 113 {
126 if (a->init) 114 if (a->init)
127 { 115 {
128 UP_close(a->num); 116 close(a->num);
129 } 117 }
130 a->init=0; 118 a->init=0;
131 a->flags=BIO_FLAGS_UPLINK; 119 a->flags=0;
132 } 120 }
133 return(1); 121 return(1);
134 } 122 }
@@ -140,7 +128,7 @@ static int fd_read(BIO *b, char *out,int outl)
140 if (out != NULL) 128 if (out != NULL)
141 { 129 {
142 clear_sys_error(); 130 clear_sys_error();
143 ret=UP_read(b->num,out,outl); 131 ret=read(b->num,out,outl);
144 BIO_clear_retry_flags(b); 132 BIO_clear_retry_flags(b);
145 if (ret <= 0) 133 if (ret <= 0)
146 { 134 {
@@ -155,7 +143,7 @@ static int fd_write(BIO *b, const char *in, int inl)
155 { 143 {
156 int ret; 144 int ret;
157 clear_sys_error(); 145 clear_sys_error();
158 ret=UP_write(b->num,in,inl); 146 ret=write(b->num,in,inl);
159 BIO_clear_retry_flags(b); 147 BIO_clear_retry_flags(b);
160 if (ret <= 0) 148 if (ret <= 0)
161 { 149 {
@@ -175,11 +163,11 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
175 case BIO_CTRL_RESET: 163 case BIO_CTRL_RESET:
176 num=0; 164 num=0;
177 case BIO_C_FILE_SEEK: 165 case BIO_C_FILE_SEEK:
178 ret=(long)UP_lseek(b->num,num,0); 166 ret=(long)lseek(b->num,num,0);
179 break; 167 break;
180 case BIO_C_FILE_TELL: 168 case BIO_C_FILE_TELL:
181 case BIO_CTRL_INFO: 169 case BIO_CTRL_INFO:
182 ret=(long)UP_lseek(b->num,0,1); 170 ret=(long)lseek(b->num,0,1);
183 break; 171 break;
184 case BIO_C_SET_FD: 172 case BIO_C_SET_FD:
185 fd_free(b); 173 fd_free(b);