Skip to content
Snippets Groups Projects
Unverified Commit 51a17084 authored by Matthias Schiffer's avatar Matthias Schiffer Committed by GitHub
Browse files

gluon-neighbour-info: avoid recv() with NULL buffer (#2323)

Calling functions like recv() with a NULL buffer is not explicitly
allowed by the POSIX standard, so it must be avoided to be portable
across different libc implementations. Allocate an initial buffer before
handling requests, and also pass this buffer to the peek recv() call.

Fixes: 531937cf ("gluon-neighbour-info: fix broken output with large results")
parent f910cab6
No related branches found
No related tags found
No related merge requests found
......@@ -95,7 +95,7 @@ ssize_t recvtimeout(int socket, char **recvbuffer, size_t *recvbuffer_len,
setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &timeout_left, sizeof(timeout_left));
recvlen = recv(socket, NULL, 0, MSG_PEEK | MSG_TRUNC);
recvlen = recv(socket, *recvbuffer, 0, MSG_PEEK | MSG_TRUNC);
if (recvlen < 0)
return recvlen;
......@@ -269,6 +269,8 @@ int main(int argc, char **argv) {
fflush(stdout);
}
resize_recvbuffer(&recvbuffer, &recvbuffer_len, 8192);
do {
ret = request(sock, &recvbuffer, &recvbuffer_len, &client_addr,
request_string, sse, timeout, max_count);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment