[PATCH] close_range: fd and max_fd are unsigned

Alyssa Ross hi at alyssa.is
Thu Mar 25 03:55:54 UTC 2021


The distinction is important, because close_range(2) says that having
max_fd < fd is an error, but if you give the kernel 1U + INT_MAX as
max_fd, it'll interpret it as unsigned.

Since we're working with ranges of file descriptors here, the
particular properties of only the start and end file descriptors
aren't really relevant, so it doesn't matter that we're losing fancy
file descriptor printing in making this change.

Signed-off-by: Alyssa Ross <hi at alyssa.is>
---
 src/close_range.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/close_range.c b/src/close_range.c
index 3b11c170..4c267bdc 100644
--- a/src/close_range.c
+++ b/src/close_range.c
@@ -12,11 +12,11 @@
 SYS_FUNC(close_range)
 {
 	/* fd */
-	printfd(tcp, tcp->u_arg[0]);
+	tprintf("%u", (unsigned int)tcp->u_arg[0]);
 	tprint_arg_next();
 
 	/* max_fd */
-	printfd(tcp, tcp->u_arg[1]);
+	tprintf("%u", (unsigned int)tcp->u_arg[1]);
 	tprint_arg_next();
 
 	/* flags */
-- 
2.30.0



More information about the Strace-devel mailing list