Commit dbaffde7 authored by Mark Salyzyn's avatar Mark Salyzyn Committed by Tony Luck

pstore: Use scnprintf() in pstore_mkfile()

No guarantees that the names will not exceed the
name buffer with future adjustments.
Signed-off-by: default avatarMark Salyzyn <salyzyn@android.com>
Acked-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent eaa27f34
...@@ -338,32 +338,35 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count, ...@@ -338,32 +338,35 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
switch (type) { switch (type) {
case PSTORE_TYPE_DMESG: case PSTORE_TYPE_DMESG:
sprintf(name, "dmesg-%s-%lld%s", psname, id, scnprintf(name, sizeof(name), "dmesg-%s-%lld%s",
compressed ? ".enc.z" : ""); psname, id, compressed ? ".enc.z" : "");
break; break;
case PSTORE_TYPE_CONSOLE: case PSTORE_TYPE_CONSOLE:
sprintf(name, "console-%s-%lld", psname, id); scnprintf(name, sizeof(name), "console-%s-%lld", psname, id);
break; break;
case PSTORE_TYPE_FTRACE: case PSTORE_TYPE_FTRACE:
sprintf(name, "ftrace-%s-%lld", psname, id); scnprintf(name, sizeof(name), "ftrace-%s-%lld", psname, id);
break; break;
case PSTORE_TYPE_MCE: case PSTORE_TYPE_MCE:
sprintf(name, "mce-%s-%lld", psname, id); scnprintf(name, sizeof(name), "mce-%s-%lld", psname, id);
break; break;
case PSTORE_TYPE_PPC_RTAS: case PSTORE_TYPE_PPC_RTAS:
sprintf(name, "rtas-%s-%lld", psname, id); scnprintf(name, sizeof(name), "rtas-%s-%lld", psname, id);
break; break;
case PSTORE_TYPE_PPC_OF: case PSTORE_TYPE_PPC_OF:
sprintf(name, "powerpc-ofw-%s-%lld", psname, id); scnprintf(name, sizeof(name), "powerpc-ofw-%s-%lld",
psname, id);
break; break;
case PSTORE_TYPE_PPC_COMMON: case PSTORE_TYPE_PPC_COMMON:
sprintf(name, "powerpc-common-%s-%lld", psname, id); scnprintf(name, sizeof(name), "powerpc-common-%s-%lld",
psname, id);
break; break;
case PSTORE_TYPE_UNKNOWN: case PSTORE_TYPE_UNKNOWN:
sprintf(name, "unknown-%s-%lld", psname, id); scnprintf(name, sizeof(name), "unknown-%s-%lld", psname, id);
break; break;
default: default:
sprintf(name, "type%d-%s-%lld", type, psname, id); scnprintf(name, sizeof(name), "type%d-%s-%lld",
type, psname, id);
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment