Messages in this thread | | | Subject | Re: [PATCH 1/3] pstore: use snprintf | From | Joe Perches <> | Date | Tue, 06 Jan 2015 09:20:37 -0800 |
| |
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" : "");
| |