diff mbox series

[liburing,1/2] fix int shortening bug in io_uring_recvmsg_validate

Message ID 20221019145042.446477-2-dylany@meta.com (mailing list archive)
State New
Headers show
Series liburing: fix shortening api issues | expand

Commit Message

Dylan Yudaken Oct. 19, 2022, 2:50 p.m. UTC
Fix for compilers running with -Wshorten-64-to-32

Fixes: 874406f7fb09 ("add multishot recvmsg API")
Signed-off-by: Dylan Yudaken <dylany@meta.com>
---
 src/include/liburing.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 1d049230ddfb..118bba9eea15 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -791,10 +791,9 @@  static inline void io_uring_prep_recv_multishot(struct io_uring_sqe *sqe,
 static inline struct io_uring_recvmsg_out *
 io_uring_recvmsg_validate(void *buf, int buf_len, struct msghdr *msgh)
 {
-	int header = msgh->msg_controllen + msgh->msg_namelen +
+	unsigned long header = msgh->msg_controllen + msgh->msg_namelen +
 				sizeof(struct io_uring_recvmsg_out);
-
-	if (buf_len < header)
+	if (buf_len < 0 || (unsigned long)buf_len < header)
 		return NULL;
 	return (struct io_uring_recvmsg_out *)buf;
 }