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
diff --git a/libc/stdio/local.h b/libc/stdio/local.h
index ab31af1..441fcfe 100644
--- a/libc/stdio/local.h
+++ b/libc/stdio/local.h
@@ -231,8 +231,6 @@
 #define FUNLOCKFILE(fp) \
   if (!_EXT(fp)->_caller_handles_locking) funlockfile(fp)
 
-#define NO_PRINTF_PERCENT_N
-
 /* OpenBSD exposes these in <stdio.h>, but we only want them exposed to the implementation. */
 #define __sferror(p) (((p)->_flags & __SERR) != 0)
 #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR | __SEOF)))
diff --git a/libc/stdio/printf_common.h b/libc/stdio/printf_common.h
index 050120e..85c91de 100644
--- a/libc/stdio/printf_common.h
+++ b/libc/stdio/printf_common.h
@@ -499,24 +499,8 @@
         else
           ADDTYPE(T_DOUBLE);
         break;
-#ifndef NO_PRINTF_PERCENT_N
       case 'n':
-        if (flags & LLONGINT)
-          ADDTYPE(TP_LLONG);
-        else if (flags & LONGINT)
-          ADDTYPE(TP_LONG);
-        else if (flags & SHORTINT)
-          ADDTYPE(TP_SHORT);
-        else if (flags & PTRINT)
-          ADDTYPE(TP_PTRINT);
-        else if (flags & SIZEINT)
-          ADDTYPE(TP_SSIZEINT);
-        else if (flags & MAXINT)
-          ADDTYPE(TP_MAXINT);
-        else
-          ADDTYPE(TP_INT);
-        continue; /* no output */
-#endif            /* NO_PRINTF_PERCENT_N */
+        __fortify_fatal("%%n not allowed on Android");
       case 'O':
         flags |= LONGINT;
         /*FALLTHROUGH*/
diff --git a/libc/stdio/vfprintf.cpp b/libc/stdio/vfprintf.cpp
index 9182880..17e4372 100644
--- a/libc/stdio/vfprintf.cpp
+++ b/libc/stdio/vfprintf.cpp
@@ -449,26 +449,8 @@
           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*/
diff --git a/libc/stdio/vfwprintf.cpp b/libc/stdio/vfwprintf.cpp
index 7a00202..46b6233 100644
--- a/libc/stdio/vfwprintf.cpp
+++ b/libc/stdio/vfwprintf.cpp
@@ -434,26 +434,8 @@
           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*/