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