summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/printf.3
diff options
context:
space:
mode:
authorEric Melville <eric@FreeBSD.org>2001-05-25 20:42:40 +0000
committerEric Melville <eric@FreeBSD.org>2001-05-25 20:42:40 +0000
commit2de21960267bf0a1c33d2a13c07402ee757d8161 (patch)
treeed53d069b8e91b894b84f7de41a356db6acd77b0 /lib/libc/stdio/printf.3
parentfe95b4649122be8b7d5f666f52c96df8cdf94f87 (diff)
Notes
Diffstat (limited to 'lib/libc/stdio/printf.3')
-rw-r--r--lib/libc/stdio/printf.314
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/libc/stdio/printf.3 b/lib/libc/stdio/printf.3
index 30b02a653300..590c1c0bfddb 100644
--- a/lib/libc/stdio/printf.3
+++ b/lib/libc/stdio/printf.3
@@ -664,3 +664,17 @@ For safety, programmers should use the
.Fn snprintf
interface instead.
Unfortunately, this interface is not portable.
+.Pp
+Never pass a string with user-supplied data as a format without using
+.Ql %s .
+An attacker can put format specifiers in the string to mangle your stack,
+leading to a possible security hole.
+This holds true even if the string was built using a function like
+.Fn snprintf ,
+as the resulting string may still contain user-supplied conversion specifiers
+for later interpolation by
+.Fn printf .
+.Pp
+Always use the proper secure idiom:
+.Pp
+.Dl snprintf(buffer, sizeof(buffer), "%s", string);