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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix for compilers running with -Wshorten-64-to-32

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

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;
 }
-- 
2.30.2





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux