From: Mark Salyzyn Date: Mon, 8 Dec 2014 23:06:52 +0000 (-0800) Subject: [PATCH v4 1/5] pstore: use snprintf X-Git-Tag: firefly_0821_release~4090^2~100 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3797dc2dca25d4a89ff171990c4e6dba827b8e3d;p=firefly-linux-kernel-4.4.55.git [PATCH v4 1/5] pstore: use snprintf No guarantees that the names will not exceed the name buffer with future adjustments. Signed-off-by: Mark Salyzyn Acked-by: Joe Perches v2: switch from snprintf to scnprintf v3: remove embedded space v4: renumber pmsg series dependencies Change-Id: I161fe8cadc967d74e18cc09b7d60b5b398c92c86 --- diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index e4bcb2cf055a..ae977dd0e426 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c @@ -313,22 +313,24 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count, switch (type) { case PSTORE_TYPE_DMESG: - sprintf(name, "dmesg-%s-%lld", psname, id); + scnprintf(name, sizeof(name), "dmesg-%s-%lld", + psname, id); break; case PSTORE_TYPE_CONSOLE: - sprintf(name, "console-%s", psname); + scnprintf(name, sizeof(name), "console-%s", psname); break; case PSTORE_TYPE_FTRACE: - sprintf(name, "ftrace-%s", psname); + scnprintf(name, sizeof(name), "ftrace-%s", psname); break; case PSTORE_TYPE_MCE: - sprintf(name, "mce-%s-%lld", psname, id); + scnprintf(name, sizeof(name), "mce-%s-%lld", psname, id); break; case PSTORE_TYPE_UNKNOWN: - sprintf(name, "unknown-%s-%lld", psname, id); + scnprintf(name, sizeof(name), "unknown-%s-%lld", psname, id); break; default: - sprintf(name, "type%d-%s-%lld", type, psname, id); + scnprintf(name, sizeof(name), "type%d-%s-%lld", + type, psname, id); break; }