dcavalca / rpms / linuxptp

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