diff mbox series

pcrypt: use format specifier in kobject_add

Message ID 20181027144926.8433-1-colin.king@canonical.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series pcrypt: use format specifier in kobject_add | expand

Commit Message

Colin King Oct. 27, 2018, 2:49 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Passing string 'name' as the format specifier is potentially hazardous
because name could (although very unlikely to) have a format specifier
embedded in it causing issues when parsing the non-existent arguments
to these.  Follow best practice by using the "%s" format string for
the string 'name'.

Cleans up clang warning:
crypto/pcrypt.c:397:40: warning: format string is not a string literal
(potentially insecure) [-Wformat-security]

Fixes: a3fb1e330dd2 ("pcrypt: Added sysfs interface to pcrypt")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 crypto/pcrypt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Herbert Xu Nov. 9, 2018, 9:53 a.m. UTC | #1
On Sat, Oct 27, 2018 at 03:49:26PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Passing string 'name' as the format specifier is potentially hazardous
> because name could (although very unlikely to) have a format specifier
> embedded in it causing issues when parsing the non-existent arguments
> to these.  Follow best practice by using the "%s" format string for
> the string 'name'.
> 
> Cleans up clang warning:
> crypto/pcrypt.c:397:40: warning: format string is not a string literal
> (potentially insecure) [-Wformat-security]
> 
> Fixes: a3fb1e330dd2 ("pcrypt: Added sysfs interface to pcrypt")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  crypto/pcrypt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
index f8ec3d4ba4a8..29d2cf989c05 100644
--- a/crypto/pcrypt.c
+++ b/crypto/pcrypt.c
@@ -394,7 +394,7 @@  static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
 	int ret;
 
 	pinst->kobj.kset = pcrypt_kset;
-	ret = kobject_add(&pinst->kobj, NULL, name);
+	ret = kobject_add(&pinst->kobj, NULL, "%s", name);
 	if (!ret)
 		kobject_uevent(&pinst->kobj, KOBJ_ADD);