liburing: fix shortening api issues
cover liburing: fix shortening api issues
The liburing public API has a couple of int shortening issues found by compiling with cc="clang -Wshorten-64-to-32 -Werror"
There are a few more in the main library, and a *lot* in the tests, which would be nice to fix up at some point. The public API changes are particularly useful for build systems that include these files and run with these errors enabled.
Dylan Yudaken (2):
fix int shortening bug in io_uring_recvmsg_validate fix len type of fgettxattr etc
src/include/liburing.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
base-commit: 13f3fe3af811d8508676dbd1ef552f2b459e1b21
Signature · 1 line
2.30.2
PATCH 1/2 fix int shortening bug in io_uring_recvmsg_validate
Fix for compilers running with -Wshorten-64-to-32
--- src/include/liburing.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
src/include/liburing.h +2 -3
@@ -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; }
Signature · 1 line
2.30.2
PATCH 2/2 fix len type of fgettxattr etc
In reply to Dylan YudakenThe size_t len was passed to an unsigned int directly.
Take an unsigned int instead which is what is expected by io_uring_prep_rw
--- src/include/liburing.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
src/include/liburing.h +9 -9
@@ -991,7 +991,7 @@ static inline void io_uring_prep_getxattr(struct io_uring_sqe *sqe,const char *name, char *value, const char *path, - size_t len) + unsigned int len) { io_uring_prep_rw(IORING_OP_GETXATTR, sqe, 0, name, len, (__u64) (uintptr_t ) value);
@@ -1004,7 +1004,7 @@ static inline void io_uring_prep_setxattr(struct io_uring_sqe *sqe,const char *value, const char *path, int flags, - size_t len) + unsigned int len) { io_uring_prep_rw(IORING_OP_SETXATTR, sqe, 0, name, len, (__u64) (uintptr_t ) value);
@@ -1013,10 +1013,10 @@ static inline void io_uring_prep_setxattr(struct io_uring_sqe *sqe, }static inline void io_uring_prep_fgetxattr (struct io_uring_sqe *sqe, -int fd, +int fd,const char *name,char *value, -size_t len) +unsigned int len) {io_uring_prep_rw (IORING_OP_FGETXATTR , sqe, fd, name, len, (__u64 ) (uintptr_t ) value);
@@ -1024,11 +1024,11 @@ static inline void io_uring_prep_fgetxattr(struct io_uring_sqe *sqe, }static inline void io_uring_prep_fsetxattr (struct io_uring_sqe *sqe, -int fd, -const char *name, -const char *value, -int flags, -size_t len) +int fd, +const char *name, +const char *value, +int flags, +unsigned int len) {io_uring_prep_rw (IORING_OP_FSETXATTR , sqe, fd, name, len, (__u64 ) (uintptr_t ) value);
Signature · 1 line
2.30.2
Quoted 9 lines · Dylan Yudaken
The liburing public API has a couple of int shortening issues found by compiling with cc="clang -Wshorten-64-to-32 -Werror"
There are a few more in the main library, and a *lot* in the tests, which would be nice to fix up at some point. The public API changes are particularly useful for build systems that include these files and run with these errors enabled.
[...]
Applied, thanks!
[1/2] fix int shortening bug in io_uring_recvmsg_validate
commit: d916aa80993438dbcec700202b21b550edc03941
[2/2] fix len type of fgettxattr etc
commit: 5698e179a1308aa8019a482ca910a832b5737e5fBest regards,
Signature · 1 line
Jens Axboe
Quoted 7 lines · Dylan Yudaken
The liburing public API has a couple of int shortening issues found by compiling with cc="clang -Wshorten-64-to-32 -Werror"
There are a few more in the main library, and a *lot* in the tests, which would be nice to fix up at some point. The public API changes are particularly useful for build systems that include these files and run with these errors enabled.
Let's clean the main library up, but ignore the tests for now. I'll send a cleanup series for review before the release.
Signature · 1 line
Ammar Faizi