diff options
Diffstat (limited to 'src/lib/libcrypto/bio/bss_fd.c')
-rw-r--r-- | src/lib/libcrypto/bio/bss_fd.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/lib/libcrypto/bio/bss_fd.c b/src/lib/libcrypto/bio/bss_fd.c index c0e7f08fbb..988104e77c 100644 --- a/src/lib/libcrypto/bio/bss_fd.c +++ b/src/lib/libcrypto/bio/bss_fd.c | |||
@@ -67,19 +67,7 @@ | |||
67 | * BIO_s_fd here... | 67 | * BIO_s_fd here... |
68 | */ | 68 | */ |
69 | #else | 69 | #else |
70 | /* | 70 | #include <openssl/bio.h> |
71 | * As for unconditional usage of "UPLINK" interface in this module. | ||
72 | * Trouble is that unlike Unix file descriptors [which are indexes | ||
73 | * in kernel-side per-process table], corresponding descriptors on | ||
74 | * platforms which require "UPLINK" interface seem to be indexes | ||
75 | * in a user-land, non-global table. Well, in fact they are indexes | ||
76 | * in stdio _iob[], and recall that _iob[] was the very reason why | ||
77 | * "UPLINK" interface was introduced in first place. But one way on | ||
78 | * another. Neither libcrypto or libssl use this BIO meaning that | ||
79 | * file descriptors can only be provided by application. Therefore | ||
80 | * "UPLINK" calls are due... | ||
81 | */ | ||
82 | #include "bio_lcl.h" | ||
83 | 71 | ||
84 | static int fd_write(BIO *h, const char *buf, int num); | 72 | static int fd_write(BIO *h, const char *buf, int num); |
85 | static int fd_read(BIO *h, char *buf, int size); | 73 | static int fd_read(BIO *h, char *buf, int size); |
@@ -125,7 +113,7 @@ fd_new(BIO *bi) | |||
125 | bi->init = 0; | 113 | bi->init = 0; |
126 | bi->num = -1; | 114 | bi->num = -1; |
127 | bi->ptr = NULL; | 115 | bi->ptr = NULL; |
128 | bi->flags=BIO_FLAGS_UPLINK; /* essentially redundant */ | 116 | bi->flags=0; |
129 | return (1); | 117 | return (1); |
130 | } | 118 | } |
131 | 119 | ||
@@ -136,10 +124,10 @@ fd_free(BIO *a) | |||
136 | return (0); | 124 | return (0); |
137 | if (a->shutdown) { | 125 | if (a->shutdown) { |
138 | if (a->init) { | 126 | if (a->init) { |
139 | UP_close(a->num); | 127 | close(a->num); |
140 | } | 128 | } |
141 | a->init = 0; | 129 | a->init = 0; |
142 | a->flags = BIO_FLAGS_UPLINK; | 130 | a->flags = 0; |
143 | } | 131 | } |
144 | return (1); | 132 | return (1); |
145 | } | 133 | } |
@@ -151,7 +139,7 @@ fd_read(BIO *b, char *out, int outl) | |||
151 | 139 | ||
152 | if (out != NULL) { | 140 | if (out != NULL) { |
153 | errno = 0; | 141 | errno = 0; |
154 | ret = UP_read(b->num, out, outl); | 142 | ret = read(b->num, out, outl); |
155 | BIO_clear_retry_flags(b); | 143 | BIO_clear_retry_flags(b); |
156 | if (ret <= 0) { | 144 | if (ret <= 0) { |
157 | if (BIO_fd_should_retry(ret)) | 145 | if (BIO_fd_should_retry(ret)) |
@@ -166,7 +154,7 @@ fd_write(BIO *b, const char *in, int inl) | |||
166 | { | 154 | { |
167 | int ret; | 155 | int ret; |
168 | errno = 0; | 156 | errno = 0; |
169 | ret = UP_write(b->num, in, inl); | 157 | ret = write(b->num, in, inl); |
170 | BIO_clear_retry_flags(b); | 158 | BIO_clear_retry_flags(b); |
171 | if (ret <= 0) { | 159 | if (ret <= 0) { |
172 | if (BIO_fd_should_retry(ret)) | 160 | if (BIO_fd_should_retry(ret)) |
@@ -185,11 +173,11 @@ fd_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
185 | case BIO_CTRL_RESET: | 173 | case BIO_CTRL_RESET: |
186 | num = 0; | 174 | num = 0; |
187 | case BIO_C_FILE_SEEK: | 175 | case BIO_C_FILE_SEEK: |
188 | ret = (long)UP_lseek(b->num, num, 0); | 176 | ret = (long)lseek(b->num, num, 0); |
189 | break; | 177 | break; |
190 | case BIO_C_FILE_TELL: | 178 | case BIO_C_FILE_TELL: |
191 | case BIO_CTRL_INFO: | 179 | case BIO_CTRL_INFO: |
192 | ret = (long)UP_lseek(b->num, 0, 1); | 180 | ret = (long)lseek(b->num, 0, 1); |
193 | break; | 181 | break; |
194 | case BIO_C_SET_FD: | 182 | case BIO_C_SET_FD: |
195 | fd_free(b); | 183 | fd_free(b); |