public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] exec: make printable macro more concise
@ 2024-11-16  6:12 Nir Lichtman
  2024-11-16  7:28 ` Al Viro
  0 siblings, 1 reply; 9+ messages in thread
From: Nir Lichtman @ 2024-11-16  6:12 UTC (permalink / raw)
  To: ebiederm, kees, viro, brauner, jack, linux-kernel

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@lichtman.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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-11-18 17:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-16  6:12 [PATCH v2] exec: make printable macro more concise Nir Lichtman
2024-11-16  7:28 ` Al Viro
2024-11-16 16:49   ` Linus Torvalds
2024-11-16 17:23     ` Nir Lichtman
2024-11-16 22:06       ` Al Viro
2024-11-16 22:38         ` Nir Lichtman
2024-11-16 21:48     ` Al Viro
2024-11-18 11:46     ` Rasmus Villemoes
2024-11-18 17:07       ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox