]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
chunk: Fallback to recv() on Windows chunk_from_fd() when operating on socket
authorMartin Willi <martin@revosec.ch>
Thu, 21 Nov 2013 15:27:50 +0000 (16:27 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 4 Jun 2014 13:53:04 +0000 (15:53 +0200)
src/libstrongswan/utils/chunk.c

index dd84d5106caff71c237a9125c77476d597f6caaa..7958931d069aa727cd5f8cb1fd524e7735e56e58 100644 (file)
@@ -269,6 +269,12 @@ bool chunk_from_fd(int fd, chunk_t *out)
        while (TRUE)
        {
                len = read(fd, buf + total, bufsize - total);
+#ifdef WIN32
+               if (len == -1 && errno == EBADF)
+               {       /* operating on a Winsock socket? */
+                       len = recv(fd, buf + total, bufsize - total, 0);
+               }
+#endif
                if (len < 0)
                {
                        free(buf);