提交 f02147ef 编写于 作者: C Chen Gang 提交者: Linus Torvalds

kernel/sysctl_binary.c: use scnprintf() instead of snprintf()

snprintf() will return the 'ideal' length which may be larger than real
buffer length, if we only want to use real length, need use scnprintf()
instead of.
Signed-off-by: NChen Gang <gang.chen@asianux.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 7833819d
...@@ -1024,7 +1024,7 @@ static ssize_t bin_intvec(struct file *file, ...@@ -1024,7 +1024,7 @@ static ssize_t bin_intvec(struct file *file,
if (get_user(value, vec + i)) if (get_user(value, vec + i))
goto out_kfree; goto out_kfree;
str += snprintf(str, end - str, "%lu\t", value); str += scnprintf(str, end - str, "%lu\t", value);
} }
result = kernel_write(file, buffer, str - buffer, 0); result = kernel_write(file, buffer, str - buffer, 0);
...@@ -1095,7 +1095,7 @@ static ssize_t bin_ulongvec(struct file *file, ...@@ -1095,7 +1095,7 @@ static ssize_t bin_ulongvec(struct file *file,
if (get_user(value, vec + i)) if (get_user(value, vec + i))
goto out_kfree; goto out_kfree;
str += snprintf(str, end - str, "%lu\t", value); str += scnprintf(str, end - str, "%lu\t", value);
} }
result = kernel_write(file, buffer, str - buffer, 0); result = kernel_write(file, buffer, str - buffer, 0);
...@@ -1205,7 +1205,7 @@ static ssize_t bin_dn_node_address(struct file *file, ...@@ -1205,7 +1205,7 @@ static ssize_t bin_dn_node_address(struct file *file,
if (get_user(dnaddr, (__le16 __user *)newval)) if (get_user(dnaddr, (__le16 __user *)newval))
goto out; goto out;
len = snprintf(buf, sizeof(buf), "%hu.%hu", len = scnprintf(buf, sizeof(buf), "%hu.%hu",
le16_to_cpu(dnaddr) >> 10, le16_to_cpu(dnaddr) >> 10,
le16_to_cpu(dnaddr) & 0x3ff); le16_to_cpu(dnaddr) & 0x3ff);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册