mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nir Lichtman <nir@lichtman.org>
To: ebiederm@xmission.com, kees@kernel.org, viro@zeniv.linux.org.uk,
	brauner@kernel.org, jack@suse.cz, linux-kernel@vger.kernel.org
Subject: [PATCH v2] exec: make printable macro more concise
Date: Sat, 16 Nov 2024 06:12:58 +0000	[thread overview]
Message-ID: <20241116061258.GA216473@lichtman.org> (raw)

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


             reply	other threads:[~2024-11-16  6:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-16  6:12 Nir Lichtman [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241116061258.GA216473@lichtman.org \
    --to=nir@lichtman.org \
    --cc=brauner@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=jack@suse.cz \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®