diff options
author | Chen Gang <gang.chen@asianux.com> | 2013-08-20 02:05:04 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2013-08-20 02:07:46 -0400 |
commit | f4940ab7c5992d3fabcda039744fb7657749798e (patch) | |
tree | ea8a5bb3f5c93a0cef4c0e91ad87017f299bfdec /kernel/params.c | |
parent | cc56ded3fdd365e07e03315379ee6612a68fd817 (diff) |
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>
Diffstat (limited to 'kernel/params.c')
-rw-r--r-- | kernel/params.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/kernel/params.c b/kernel/params.c index ec4299cfade8..e5f8f17e57cf 100644 --- a/kernel/params.c +++ b/kernel/params.c | |||
@@ -241,7 +241,8 @@ int parse_args(const char *doing, | |||
241 | } \ | 241 | } \ |
242 | int param_get_##name(char *buffer, const struct kernel_param *kp) \ | 242 | int param_get_##name(char *buffer, const struct kernel_param *kp) \ |
243 | { \ | 243 | { \ |
244 | return sprintf(buffer, format, *((type *)kp->arg)); \ | 244 | return scnprintf(buffer, PAGE_SIZE, format, \ |
245 | *((type *)kp->arg)); \ | ||
245 | } \ | 246 | } \ |
246 | struct kernel_param_ops param_ops_##name = { \ | 247 | struct kernel_param_ops param_ops_##name = { \ |
247 | .set = param_set_##name, \ | 248 | .set = param_set_##name, \ |
@@ -285,7 +286,7 @@ EXPORT_SYMBOL(param_set_charp); | |||
285 | 286 | ||
286 | int param_get_charp(char *buffer, const struct kernel_param *kp) | 287 | int param_get_charp(char *buffer, const struct kernel_param *kp) |
287 | { | 288 | { |
288 | return sprintf(buffer, "%s", *((char **)kp->arg)); | 289 | return scnprintf(buffer, PAGE_SIZE, "%s", *((char **)kp->arg)); |
289 | } | 290 | } |
290 | EXPORT_SYMBOL(param_get_charp); | 291 | EXPORT_SYMBOL(param_get_charp); |
291 | 292 | ||
@@ -829,7 +830,7 @@ ssize_t __modver_version_show(struct module_attribute *mattr, | |||
829 | struct module_version_attribute *vattr = | 830 | struct module_version_attribute *vattr = |
830 | container_of(mattr, struct module_version_attribute, mattr); | 831 | container_of(mattr, struct module_version_attribute, mattr); |
831 | 832 | ||
832 | return sprintf(buf, "%s\n", vattr->version); | 833 | return scnprintf(buf, PAGE_SIZE, "%s\n", vattr->version); |
833 | } | 834 | } |
834 | 835 | ||
835 | extern const struct module_version_attribute *__start___modver[]; | 836 | extern const struct module_version_attribute *__start___modver[]; |