diff options
author | Mark Salyzyn <salyzyn@android.com> | 2015-01-06 14:18:24 -0500 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2015-01-16 18:30:50 -0500 |
commit | dbaffde76405012778b8815b7721554b1302038e (patch) | |
tree | 34711f45f0700477fd1d35d34b6aa8f8ad4e6848 /fs/pstore | |
parent | eaa27f34e91a14cdceed26ed6c6793ec1d186115 (diff) |
pstore: Use scnprintf() in pstore_mkfile()
No guarantees that the names will not exceed the
name buffer with future adjustments.
Signed-off-by: Mark Salyzyn <salyzyn@android.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'fs/pstore')
-rw-r--r-- | fs/pstore/inode.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index 50416602774d..d69586f09ffd 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c | |||
@@ -338,32 +338,35 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count, | |||
338 | 338 | ||
339 | switch (type) { | 339 | switch (type) { |
340 | case PSTORE_TYPE_DMESG: | 340 | case PSTORE_TYPE_DMESG: |
341 | sprintf(name, "dmesg-%s-%lld%s", psname, id, | 341 | scnprintf(name, sizeof(name), "dmesg-%s-%lld%s", |
342 | compressed ? ".enc.z" : ""); | 342 | psname, id, compressed ? ".enc.z" : ""); |
343 | break; | 343 | break; |
344 | case PSTORE_TYPE_CONSOLE: | 344 | case PSTORE_TYPE_CONSOLE: |
345 | sprintf(name, "console-%s-%lld", psname, id); | 345 | scnprintf(name, sizeof(name), "console-%s-%lld", psname, id); |
346 | break; | 346 | break; |
347 | case PSTORE_TYPE_FTRACE: | 347 | case PSTORE_TYPE_FTRACE: |
348 | sprintf(name, "ftrace-%s-%lld", psname, id); | 348 | scnprintf(name, sizeof(name), "ftrace-%s-%lld", psname, id); |
349 | break; | 349 | break; |
350 | case PSTORE_TYPE_MCE: | 350 | case PSTORE_TYPE_MCE: |
351 | sprintf(name, "mce-%s-%lld", psname, id); | 351 | scnprintf(name, sizeof(name), "mce-%s-%lld", psname, id); |
352 | break; | 352 | break; |
353 | case PSTORE_TYPE_PPC_RTAS: | 353 | case PSTORE_TYPE_PPC_RTAS: |
354 | sprintf(name, "rtas-%s-%lld", psname, id); | 354 | scnprintf(name, sizeof(name), "rtas-%s-%lld", psname, id); |
355 | break; | 355 | break; |
356 | case PSTORE_TYPE_PPC_OF: | 356 | case PSTORE_TYPE_PPC_OF: |
357 | sprintf(name, "powerpc-ofw-%s-%lld", psname, id); | 357 | scnprintf(name, sizeof(name), "powerpc-ofw-%s-%lld", |
358 | psname, id); | ||
358 | break; | 359 | break; |
359 | case PSTORE_TYPE_PPC_COMMON: | 360 | case PSTORE_TYPE_PPC_COMMON: |
360 | sprintf(name, "powerpc-common-%s-%lld", psname, id); | 361 | scnprintf(name, sizeof(name), "powerpc-common-%s-%lld", |
362 | psname, id); | ||
361 | break; | 363 | break; |
362 | case PSTORE_TYPE_UNKNOWN: | 364 | case PSTORE_TYPE_UNKNOWN: |
363 | sprintf(name, "unknown-%s-%lld", psname, id); | 365 | scnprintf(name, sizeof(name), "unknown-%s-%lld", psname, id); |
364 | break; | 366 | break; |
365 | default: | 367 | default: |
366 | sprintf(name, "type%d-%s-%lld", type, psname, id); | 368 | scnprintf(name, sizeof(name), "type%d-%s-%lld", |
369 | type, psname, id); | ||
367 | break; | 370 | break; |
368 | } | 371 | } |
369 | 372 | ||