mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
kernel/params.c: use scnprintf() instead of sprintf()
For some strings (e.g. version string), they are permitted to be larger than PAGE_SIZE (although meaningless), so recommend to use scnprintf() instead of sprintf(). Signed-off-by: Chen Gang <gang.chen@asianux.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
cc56ded3fd
commit
f4940ab7c5
@ -241,7 +241,8 @@ int parse_args(const char *doing,
|
||||
} \
|
||||
int param_get_##name(char *buffer, const struct kernel_param *kp) \
|
||||
{ \
|
||||
return sprintf(buffer, format, *((type *)kp->arg)); \
|
||||
return scnprintf(buffer, PAGE_SIZE, format, \
|
||||
*((type *)kp->arg)); \
|
||||
} \
|
||||
struct kernel_param_ops param_ops_##name = { \
|
||||
.set = param_set_##name, \
|
||||
@ -285,7 +286,7 @@ EXPORT_SYMBOL(param_set_charp);
|
||||
|
||||
int param_get_charp(char *buffer, const struct kernel_param *kp)
|
||||
{
|
||||
return sprintf(buffer, "%s", *((char **)kp->arg));
|
||||
return scnprintf(buffer, PAGE_SIZE, "%s", *((char **)kp->arg));
|
||||
}
|
||||
EXPORT_SYMBOL(param_get_charp);
|
||||
|
||||
@ -829,7 +830,7 @@ ssize_t __modver_version_show(struct module_attribute *mattr,
|
||||
struct module_version_attribute *vattr =
|
||||
container_of(mattr, struct module_version_attribute, mattr);
|
||||
|
||||
return sprintf(buf, "%s\n", vattr->version);
|
||||
return scnprintf(buf, PAGE_SIZE, "%s\n", vattr->version);
|
||||
}
|
||||
|
||||
extern const struct module_version_attribute *__start___modver[];
|
||||
|
Loading…
Reference in New Issue
Block a user