Skip to content

Commit f02147e

Browse files
Chen Gangtorvalds
authored andcommitted
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: Chen Gang <gang.chen@asianux.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7833819 commit f02147e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/sysctl_binary.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ static ssize_t bin_intvec(struct file *file,
10241024
if (get_user(value, vec + i))
10251025
goto out_kfree;
10261026

1027-
str += snprintf(str, end - str, "%lu\t", value);
1027+
str += scnprintf(str, end - str, "%lu\t", value);
10281028
}
10291029

10301030
result = kernel_write(file, buffer, str - buffer, 0);
@@ -1095,7 +1095,7 @@ static ssize_t bin_ulongvec(struct file *file,
10951095
if (get_user(value, vec + i))
10961096
goto out_kfree;
10971097

1098-
str += snprintf(str, end - str, "%lu\t", value);
1098+
str += scnprintf(str, end - str, "%lu\t", value);
10991099
}
11001100

11011101
result = kernel_write(file, buffer, str - buffer, 0);
@@ -1205,7 +1205,7 @@ static ssize_t bin_dn_node_address(struct file *file,
12051205
if (get_user(dnaddr, (__le16 __user *)newval))
12061206
goto out;
12071207

1208-
len = snprintf(buf, sizeof(buf), "%hu.%hu",
1208+
len = scnprintf(buf, sizeof(buf), "%hu.%hu",
12091209
le16_to_cpu(dnaddr) >> 10,
12101210
le16_to_cpu(dnaddr) & 0x3ff);
12111211

0 commit comments

Comments
 (0)