From cb1a271c619821d7a6caff54e133202c0a9a693f Mon Sep 17 00:00:00 2001 From: goldsimon Date: Sat, 11 Mar 2017 20:42:59 +0100 Subject: [PATCH] lwip_recvmsg: MSG_PEEK must be limited to the first iov for TCP --- src/api/sockets.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/sockets.c b/src/api/sockets.c index f5ba50d8..4abfb1b4 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -1144,8 +1144,9 @@ lwip_recvmsg(int s, struct msghdr *message, int flags) /* sum up received bytes */ ret += recvd_local; } - if ((recvd_local < 0) || (recvd_local < (int)message->msg_iov[i].iov_len)) { - /* returned prematurely */ + if ((recvd_local < 0) || (recvd_local < (int)message->msg_iov[i].iov_len) || + (flags & MSG_PEEK)) { + /* returned prematurely (or peeking, which might actually be limitated to the first iov) */ if (ret <= 0) { /* nothing received at all, propagate the error */ ret = recvd_local;