lkml.org 
[lkml]   [2015]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/3] pstore: use snprintf
From
Date
On Tue, 2015-01-06 at 09:15 -0800, Mark Salyzyn wrote:
> No guarantees that the names will not exceed the
> name buffer with future adjustments.
[]
> diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
[]
> @@ -338,32 +338,34 @@ 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%s", psname, id,
> + snprintf(name, sizeof(name), "dmesg-%s-%lld%s", psname, id,
> compressed ? ".enc.z" : "");

scnprintf to ensure null termination?

(and maybe better written like)

scnprintf(name, sizeof(name), "dmesg-%s-%lld%s",
psname, id, compressed ? ".enc.z" : "");



\
 
 \ /
  Last update: 2015-01-06 18:41    [W:0.101 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site