All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] selinuxfs: use scnprinft to get real length for inode
@ 2020-01-07  1:39 liuyang34
  2020-01-07  2:09 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: liuyang34 @ 2020-01-07  1:39 UTC (permalink / raw)
  To: Paul Moore, Stephen Smalley, Eric Paris, selinux, linux-kernel; +Cc: liuyang34

as the return value of snprintf maybe over the size of TMPBUFLEN, use scnprintf
to instead of it in sel_read_class and sel_read_perm

Signed-off-by: liuyang34 <liuyang34@xiaomi.com>
---
 security/selinux/selinuxfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index ee94fa4..376d2c0e 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1672,7 +1672,7 @@ static ssize_t sel_read_class(struct file *file, char __user *buf,
 {
 	unsigned long ino = file_inode(file)->i_ino;
 	char res[TMPBUFLEN];
-	ssize_t len = snprintf(res, sizeof(res), "%d", sel_ino_to_class(ino));
+	ssize_t len = scnprintf(res, sizeof(res), "%d", sel_ino_to_class(ino));
 	return simple_read_from_buffer(buf, count, ppos, res, len);
 }
 
@@ -1686,7 +1686,7 @@ static ssize_t sel_read_perm(struct file *file, char __user *buf,
 {
 	unsigned long ino = file_inode(file)->i_ino;
 	char res[TMPBUFLEN];
-	ssize_t len = snprintf(res, sizeof(res), "%d", sel_ino_to_perm(ino));
+	ssize_t len = scnprintf(res, sizeof(res), "%d", sel_ino_to_perm(ino));
 	return simple_read_from_buffer(buf, count, ppos, res, len);
 }
 
-- 
2.7.4


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

* Re: [PATCH v2] selinuxfs: use scnprinft to get real length for inode
  2020-01-07  1:39 [PATCH v2] selinuxfs: use scnprinft to get real length for inode liuyang34
@ 2020-01-07  2:09 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2020-01-07  2:09 UTC (permalink / raw)
  To: liuyang34; +Cc: Stephen Smalley, Eric Paris, selinux, linux-kernel, liuyang34

On Mon, Jan 6, 2020 at 8:39 PM liuyang34 <yangliuxm34@gmail.com> wrote:
>
> as the return value of snprintf maybe over the size of TMPBUFLEN, use scnprintf
> to instead of it in sel_read_class and sel_read_perm
>
> Signed-off-by: liuyang34 <liuyang34@xiaomi.com>
> ---
>  security/selinux/selinuxfs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

I corrected the typo in the subject line, and cleaned up the
description a little and merged it into selinux/next - thanks!

-- 
paul moore
www.paul-moore.com

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

end of thread, other threads:[~2020-01-07  2:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07  1:39 [PATCH v2] selinuxfs: use scnprinft to get real length for inode liuyang34
2020-01-07  2:09 ` Paul Moore

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.