[PATCH v4 1/5] pstore: use snprintf
authorMark Salyzyn <salyzyn@google.com>
Mon, 8 Dec 2014 23:06:52 +0000 (15:06 -0800)
committerMark Salyzyn <salyzyn@google.com>
Wed, 14 Jan 2015 00:18:42 +0000 (16:18 -0800)
No guarantees that the names will not exceed the
name buffer with future adjustments.

Signed-off-by: Mark Salyzyn <salyzyn@android.com>
Acked-by: Joe Perches <joe@perches.com>
v2: switch from snprintf to scnprintf
v3: remove embedded space
v4: renumber pmsg series dependencies

Change-Id: I161fe8cadc967d74e18cc09b7d60b5b398c92c86

fs/pstore/inode.c

index e4bcb2cf055a1dc8f81df7cbb38e8cdab4add0b0..ae977dd0e426f9b4dfa9168972144a77e24a41ff 100644 (file)
@@ -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;
        }