From 77ab097b7322ff0c81d91acc7ab6dbe782e5b977 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 30 Jul 2016 14:17:19 -0700 Subject: Re-impose some of Winsock's limitations on sock_recv(). In Winsock, recv() takes an int as the size argument and returns an int as a return value, so it can't read more than INT_MAX bytes. Have it take a size_t as an argument (so you don't have to cast away warnings about narrowing sizeof values), return an error if it's bigger than INT_MAX (which it can be even on ILP32 platforms, as size_t is unsigned), and have the count of remaining bytes be an int. --- sockutils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sockutils.h') diff --git a/sockutils.h b/sockutils.h index cb41b96b..c3c2a619 100644 --- a/sockutils.h +++ b/sockutils.h @@ -211,7 +211,7 @@ void sock_geterror(const char *caller, char *errbuf, int errbufsize); int sock_initaddress(const char *address, const char *port, struct addrinfo *hints, struct addrinfo **addrinfo, char *errbuf, int errbuflen); -ssize_t sock_recv(SOCKET socket, void *buffer, size_t size, int receiveall, +int sock_recv(SOCKET socket, void *buffer, size_t size, int receiveall, char *errbuf, int errbuflen); SOCKET sock_open(struct addrinfo *addrinfo, int server, int nconn, char *errbuf, int errbuflen); int sock_close(SOCKET sock, char *errbuf, int errbuflen); -- cgit v1.2.1