Skip to content

Commit

Permalink
kernel/sysctl_binary.c: use scnprintf() instead of snprintf()
Browse files Browse the repository at this point in the history
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: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Chen Gang authored and Linus Torvalds committed Nov 13, 2013
1 parent 7833819 commit f02147e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kernel/sysctl_binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ static ssize_t bin_intvec(struct file *file,
if (get_user(value, vec + i))
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);
Expand Down Expand Up @@ -1095,7 +1095,7 @@ static ssize_t bin_ulongvec(struct file *file,
if (get_user(value, vec + i))
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);
Expand Down Expand Up @@ -1205,7 +1205,7 @@ static ssize_t bin_dn_node_address(struct file *file,
if (get_user(dnaddr, (__le16 __user *)newval))
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) & 0x3ff);

Expand Down

0 comments on commit f02147e

Please sign in to comment.