dcavalca / rpms / linuxptp

Forked from rpms/linuxptp 2 years ago
Clone

Blame SOURCES/linuxptp-zerolength.patch

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