aboutsummaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2020-05-09 15:56:02 +0000
committerEd Maste <emaste@FreeBSD.org>2020-05-09 15:56:02 +0000
commit937b352e23839361e7bcbc84d0e180c1c3bb9285 (patch)
tree377a80d30913b28642fdb79b22693d5b6396808a /sys/kern
parent75c600d2870d2d14fb9b2b97bfb79a41967f9191 (diff)
downloadsrc-937b352e23839361e7bcbc84d0e180c1c3bb9285.tar.gz
src-937b352e23839361e7bcbc84d0e180c1c3bb9285.zip
remove %n support from printf(9)
It can be dangerous and there is no need for it in the kernel. Inspired by Kees Cook's change in Linux, and later OpenBSD. Reviewed by: cem, gordon, philip Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24760
Notes
Notes: svn path=/head/; revision=360849
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/subr_prf.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index 20f8b3ae3e3f..31117c4e3415 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -775,20 +775,24 @@ reswitch: switch (ch = (u_char)*fmt++) {
lflag = 1;
goto reswitch;
case 'n':
+ /*
+ * We do not support %n in kernel, but consume the
+ * argument.
+ */
if (jflag)
- *(va_arg(ap, intmax_t *)) = retval;
+ (void)va_arg(ap, intmax_t *);
else if (qflag)
- *(va_arg(ap, quad_t *)) = retval;
+ (void)va_arg(ap, quad_t *);
else if (lflag)
- *(va_arg(ap, long *)) = retval;
+ (void)va_arg(ap, long *);
else if (zflag)
- *(va_arg(ap, size_t *)) = retval;
+ (void)va_arg(ap, size_t *);
else if (hflag)
- *(va_arg(ap, short *)) = retval;
+ (void)va_arg(ap, short *);
else if (cflag)
- *(va_arg(ap, char *)) = retval;
+ (void)va_arg(ap, char *);
else
- *(va_arg(ap, int *)) = retval;
+ (void)va_arg(ap, int *);
break;
case 'o':
base = 8;