summaryrefslogtreecommitdiff
path: root/libc/stdio/vfprintf.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-03-07 13:32:58 -0800
committerElliott Hughes <enh@google.com>2018-03-07 13:32:58 -0800
commit41398d03b7e8e0dfb951660ae713e682e9fc0336 (patch)
tree802d6cf0350264fffe41021f70dbd8fe1d7c35d4 /libc/stdio/vfprintf.cpp
parent0a8d5f3eb8f4087b307f237943a19ae36b094ced (diff)
Call __fortify_fatal if printf sees %n.
We've ignored %n for a long time, but that's dangerous too because it makes it unclear whether the corresponding pointer argument should be supplied or not. Remove the ambiguity by just rejecting %n outright. Bug: http://b/31832608 Test: ran tests Change-Id: Ic046ad3436a30c6f8f580ea738bdcaeb01c858f8
Diffstat (limited to 'libc/stdio/vfprintf.cpp')
-rw-r--r--libc/stdio/vfprintf.cpp20
1 files changed, 1 insertions, 19 deletions
diff --git a/libc/stdio/vfprintf.cpp b/libc/stdio/vfprintf.cpp
index 91828801d..17e4372cd 100644
--- a/libc/stdio/vfprintf.cpp
+++ b/libc/stdio/vfprintf.cpp
@@ -449,26 +449,8 @@ int FUNCTION_NAME(FILE* fp, const CHAR_TYPE* fmt0, va_list ap) {
lead = expt;
}
break;
-#ifndef NO_PRINTF_PERCENT_N
case 'n':
- if (flags & LLONGINT)
- *GETARG(long long*) = ret;
- else if (flags & LONGINT)
- *GETARG(long*) = ret;
- else if (flags & SHORTINT)
- *GETARG(short*) = ret;
- else if (flags & CHARINT)
- *GETARG(signed char*) = ret;
- else if (flags & PTRINT)
- *GETARG(ptrdiff_t*) = ret;
- else if (flags & SIZEINT)
- *GETARG(ssize_t*) = ret;
- else if (flags & MAXINT)
- *GETARG(intmax_t*) = ret;
- else
- *GETARG(int*) = ret;
- continue; /* no output */
-#endif /* NO_PRINTF_PERCENT_N */
+ __fortify_fatal("%%n not allowed on Android");
case 'O':
flags |= LONGINT;
/*FALLTHROUGH*/