dcavalca / rpms / linuxptp

Forked from rpms/linuxptp 2 years ago
Clone

Blame SOURCES/linuxptp-zerolength.patch

3b72dd
commit 9633ab52460f58c92c6daa35e9d24e4ce9c5ab1c
3b72dd
Author: Miroslav Lichvar <mlichvar@redhat.com>
3b72dd
Date:   Tue Feb 23 11:01:43 2021 +0100
3b72dd
3b72dd
    sk: Don't return error for zero-length messages.
3b72dd
    
3b72dd
    The recvmsg() call can return zero for a zero-length UDP message, which
3b72dd
    should be handled as a bad message and not a fault of the port. This was
3b72dd
    addressed in commit 6b61ba29c78e ("Avoid fault when receiving zero
3b72dd
    length packets"), but later regressed in commit a6e0b83bd503
3b72dd
    ("sk: Convey transmit path errors to the caller.").
3b72dd
    
3b72dd
    Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
3b72dd
    Fixes: a6e0b83bd503 ("sk: Convey transmit path errors to the caller.")
3b72dd
3b72dd
diff --git a/sk.c b/sk.c
3b72dd
index c9ef4d2..8be0708 100644
3b72dd
--- a/sk.c
3b72dd
+++ b/sk.c
3b72dd
@@ -391,7 +391,7 @@ int sk_receive(int fd, void *buf, int buflen,
3b72dd
 
3b72dd
 	if (!ts) {
3b72dd
 		memset(&hwts->ts, 0, sizeof(hwts->ts));
3b72dd
-		return cnt < 1 ? -errno : cnt;
3b72dd
+		return cnt < 0 ? -errno : cnt;
3b72dd
 	}
3b72dd
 
3b72dd
 	switch (hwts->type) {
3b72dd
@@ -407,7 +407,7 @@ int sk_receive(int fd, void *buf, int buflen,
3b72dd
 		hwts->ts = timespec_to_tmv(ts[1]);
3b72dd
 		break;
3b72dd
 	}
3b72dd
-	return cnt < 1 ? -errno : cnt;
3b72dd
+	return cnt < 0 ? -errno : cnt;
3b72dd
 }
3b72dd
 
3b72dd
 int sk_set_priority(int fd, int family, uint8_t dscp)