lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y2tBJFSsyUzdb+eO@qemulion>
Date:   Wed, 9 Nov 2022 11:26:52 +0530
From:   Deepak R Varma <drv@...lo.com>
To:     outreachy@...ts.linux.dev, Sven Van Asbroeck <TheSven73@...il.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: [PATCH v2] staging: fieldbus: replace snprintf in show functions
 with sysfs_emit

The show() methods should only use sysfs_emit() when formatting values
to be returned to the user space.
Ref: Documentation/filesystems/sysfs.rst
Issue identified by coccicheck.

Signed-off-by: Deepak R Varma <drv@...lo.com>
---

Changes in v2:
   1. Switch to using sysfs_emit instead of scnprintf
   2. Update patch subject and log accordingly
      Feedback from gregkh@...uxfoundation.org


 drivers/staging/fieldbus/dev_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c
index 5aab734606ea..d32599f4eb44 100644
--- a/drivers/staging/fieldbus/dev_core.c
+++ b/drivers/staging/fieldbus/dev_core.c
@@ -67,10 +67,10 @@ static ssize_t card_name_show(struct device *dev, struct device_attribute *attr,
 	struct fieldbus_dev *fb = dev_get_drvdata(dev);

 	/*
-	 * card_name was provided by child driver, could potentially be long.
-	 * protect against buffer overrun.
+	 * sysfs provides PAGE_SIZE long buffer to take care of potentially
+	 * long card_name provided by child driver.
 	 */
-	return snprintf(buf, PAGE_SIZE, "%s\n", fb->card_name);
+	return sysfs_emit(buf, "%s\n", fb->card_name);
 }
 static DEVICE_ATTR_RO(card_name);

--
2.34.1



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ