[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241116061258.GA216473@lichtman.org>
Date: Sat, 16 Nov 2024 06:12:58 +0000
From: Nir Lichtman <nir@...htman.org>
To: ebiederm@...ssion.com, kees@...nel.org, viro@...iv.linux.org.uk,
brauner@...nel.org, jack@...e.cz, linux-kernel@...r.kernel.org
Subject: [PATCH v2] exec: make printable macro more concise
Problem: The printable macro in exec.c uses custom logic
to determine if a character is printable, even though
the kernel supplies existing facilities.
Solution: Refactor to use isprint and isspace.
Signed-off-by: Nir Lichtman <nir@...htman.org>
---
v2: fix to also consider space characters as printables
Side-note: I called the previous version "refactor an invalid
executable check to use isprint"
fs/exec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/exec.c b/fs/exec.c
index 6c53920795c2..3b4c7548427f 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1723,7 +1723,7 @@ int remove_arg_zero(struct linux_binprm *bprm)
}
EXPORT_SYMBOL(remove_arg_zero);
-#define printable(c) (((c)=='\t') || ((c)=='\n') || (0x20<=(c) && (c)<=0x7e))
+#define printable(c) (isprint(c) || isspace(c))
/*
* cycle the list of binary formats handler, until one recognizes the image
*/
--
2.39.2
Powered by blists - more mailing lists