diff options
| author | kinichiro <kinichiro.inoguchi@gmail.com> | 2019-07-28 19:03:27 +0900 |
|---|---|---|
| committer | kinichiro <kinichiro.inoguchi@gmail.com> | 2019-07-28 19:10:47 +0900 |
| commit | 856d0511d63bd791b4a18df0c3ffc80b8e47c470 (patch) | |
| tree | 09ca2423dc45ffd4fc21982de10dc19f877a5329 /crypto | |
| parent | 0e3d93fc1d008d7561e97ceccc35f092e5fc0f36 (diff) | |
| download | portable-856d0511d63bd791b4a18df0c3ffc80b8e47c470.tar.gz portable-856d0511d63bd791b4a18df0c3ffc80b8e47c470.tar.bz2 portable-856d0511d63bd791b4a18df0c3ffc80b8e47c470.zip | |
Use posix_win.c functions on WIN32
- read() returns bytes count as 1 for crlf unless binary mode isn't
specified with open(). Reported by @ulfworsoe in libressl-portable#542
- err could be WSANOTINITIALISED when WSAStartup() is not called
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/compat/posix_win.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crypto/compat/posix_win.c b/crypto/compat/posix_win.c index b73f023..4b4b5f5 100644 --- a/crypto/compat/posix_win.c +++ b/crypto/compat/posix_win.c | |||
| @@ -162,7 +162,8 @@ posix_close(int fd) | |||
| 162 | { | 162 | { |
| 163 | if (closesocket(fd) == SOCKET_ERROR) { | 163 | if (closesocket(fd) == SOCKET_ERROR) { |
| 164 | int err = WSAGetLastError(); | 164 | int err = WSAGetLastError(); |
| 165 | return (err == WSAENOTSOCK || err == WSAEBADF) ? | 165 | return (err == WSAENOTSOCK || err == WSAEBADF || |
| 166 | err == WSANOTINITIALISED) ? | ||
| 166 | close(fd) : wsa_errno(err); | 167 | close(fd) : wsa_errno(err); |
| 167 | } | 168 | } |
| 168 | return 0; | 169 | return 0; |
| @@ -174,7 +175,8 @@ posix_read(int fd, void *buf, size_t count) | |||
| 174 | ssize_t rc = recv(fd, buf, count, 0); | 175 | ssize_t rc = recv(fd, buf, count, 0); |
| 175 | if (rc == SOCKET_ERROR) { | 176 | if (rc == SOCKET_ERROR) { |
| 176 | int err = WSAGetLastError(); | 177 | int err = WSAGetLastError(); |
| 177 | return (err == WSAENOTSOCK || err == WSAEBADF) ? | 178 | return (err == WSAENOTSOCK || err == WSAEBADF || |
| 179 | err == WSANOTINITIALISED) ? | ||
| 178 | read(fd, buf, count) : wsa_errno(err); | 180 | read(fd, buf, count) : wsa_errno(err); |
| 179 | } | 181 | } |
| 180 | return rc; | 182 | return rc; |
| @@ -186,7 +188,8 @@ posix_write(int fd, const void *buf, size_t count) | |||
| 186 | ssize_t rc = send(fd, buf, count, 0); | 188 | ssize_t rc = send(fd, buf, count, 0); |
| 187 | if (rc == SOCKET_ERROR) { | 189 | if (rc == SOCKET_ERROR) { |
| 188 | int err = WSAGetLastError(); | 190 | int err = WSAGetLastError(); |
| 189 | return (err == WSAENOTSOCK || err == WSAEBADF) ? | 191 | return (err == WSAENOTSOCK || err == WSAEBADF || |
| 192 | err == WSANOTINITIALISED) ? | ||
| 190 | write(fd, buf, count) : wsa_errno(err); | 193 | write(fd, buf, count) : wsa_errno(err); |
| 191 | } | 194 | } |
| 192 | return rc; | 195 | return rc; |
