about summary refs log tree commit diff
path: root/debug
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-11-18 23:25:46 +0000
committerUlrich Drepper <drepper@redhat.com>2004-11-18 23:25:46 +0000
commit1b1d36792e9d9c4ad9a67ad8bfc1a3be8f2104c1 (patch)
tree4523c0003244e52de8da34478fc4aa201cb778bf /debug
parentfb67e07dfb5403e6008e60be9896ced594014fec (diff)
downloadglibc-1b1d36792e9d9c4ad9a67ad8bfc1a3be8f2104c1.tar.gz
glibc-1b1d36792e9d9c4ad9a67ad8bfc1a3be8f2104c1.tar.xz
glibc-1b1d36792e9d9c4ad9a67ad8bfc1a3be8f2104c1.zip
Update.
2004-11-18  Ulrich Drepper  <drepper@redhat.com>
	* libio/libio.h (_IO_FLAGS2_FORTIFY): Renamed from
	_IO_FLAGS2_CHECK_PERCENT_N.
	* debug/fprintff_chk.c: Adjust all users.
	* debug/printf_chk.c: Likewise.
	* debug/vfprintf_chk.c: Likewise.
	* debug/vprintf_chk.c: Likewise.
	* debug/vsnprintf_chk.c: Likewise.
	* debug/vsprintf_chk.c: Likewise.
	* stdio-common/vfprintf.c: Likewise.  Detect missing %N$ formats.
	* debug/tst-chk1.c: Test detection of missing %N$ formats.
Diffstat (limited to 'debug')
-rw-r--r--debug/fprintf_chk.c4
-rw-r--r--debug/printf_chk.c4
-rw-r--r--debug/tst-chk1.c17
-rw-r--r--debug/vfprintf_chk.c4
-rw-r--r--debug/vprintf_chk.c4
-rw-r--r--debug/vsnprintf_chk.c2
-rw-r--r--debug/vsprintf_chk.c2
7 files changed, 27 insertions, 10 deletions
diff --git a/debug/fprintf_chk.c b/debug/fprintf_chk.c
index 77508b902e..2b7d22b6a6 100644
--- a/debug/fprintf_chk.c
+++ b/debug/fprintf_chk.c
@@ -31,14 +31,14 @@ __fprintf_chk (FILE *fp, int flag, const char *format, ...)
 
   _IO_acquire_lock (fp);
   if (flag > 0)
-    fp->_flags2 |= _IO_FLAGS2_CHECK_PERCENT_N;
+    fp->_flags2 |= _IO_FLAGS2_FORTIFY;
 
   va_start (ap, format);
   done = vfprintf (fp, format, ap);
   va_end (ap);
 
   if (flag > 0)
-    fp->_flags2 &= ~_IO_FLAGS2_CHECK_PERCENT_N;
+    fp->_flags2 &= ~_IO_FLAGS2_FORTIFY;
   _IO_release_lock (fp);
 
   return done;
diff --git a/debug/printf_chk.c b/debug/printf_chk.c
index d2b387323d..86096b45c0 100644
--- a/debug/printf_chk.c
+++ b/debug/printf_chk.c
@@ -31,14 +31,14 @@ __printf_chk (int flag, const char *format, ...)
 
   _IO_acquire_lock (stdout);
   if (flag > 0)
-    stdout->_flags2 |= _IO_FLAGS2_CHECK_PERCENT_N;
+    stdout->_flags2 |= _IO_FLAGS2_FORTIFY;
 
   va_start (ap, format);
   done = vfprintf (stdout, format, ap);
   va_end (ap);
 
   if (flag > 0)
-    stdout->_flags2 &= ~_IO_FLAGS2_CHECK_PERCENT_N;
+    stdout->_flags2 &= ~_IO_FLAGS2_FORTIFY;
   _IO_release_lock (stdout);
 
   return done;
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index 37320c3514..0df660d57f 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -474,5 +474,22 @@ do_test (void)
   CHK_FAIL_END
 #endif
 
+  /* Check whether missing N$ formats are detected.  */
+  CHK_FAIL2_START
+  printf ("%3$d\n", 1, 2, 3, 4);
+  CHK_FAIL2_END
+
+  CHK_FAIL2_START
+  fprintf (stdout, "%3$d\n", 1, 2, 3, 4);
+  CHK_FAIL2_END
+
+  CHK_FAIL2_START
+  sprintf (buf, "%3$d\n", 1, 2, 3, 4);
+  CHK_FAIL2_END
+
+  CHK_FAIL2_START
+  snprintf (buf, sizeof (buf), "%3$d\n", 1, 2, 3, 4);
+  CHK_FAIL2_END
+
   return ret;
 }
diff --git a/debug/vfprintf_chk.c b/debug/vfprintf_chk.c
index a9e107d8e5..c8e7c3bf3f 100644
--- a/debug/vfprintf_chk.c
+++ b/debug/vfprintf_chk.c
@@ -30,12 +30,12 @@ __vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap)
 
   _IO_acquire_lock (fp);
   if (flag > 0)
-    fp->_flags2 |= _IO_FLAGS2_CHECK_PERCENT_N;
+    fp->_flags2 |= _IO_FLAGS2_FORTIFY;
 
   done = vfprintf (fp, format, ap);
 
   if (flag > 0)
-    fp->_flags2 &= ~_IO_FLAGS2_CHECK_PERCENT_N;
+    fp->_flags2 &= ~_IO_FLAGS2_FORTIFY;
   _IO_release_lock (fp);
 
   return done;
diff --git a/debug/vprintf_chk.c b/debug/vprintf_chk.c
index f477f15411..1fd5bcd849 100644
--- a/debug/vprintf_chk.c
+++ b/debug/vprintf_chk.c
@@ -30,12 +30,12 @@ __vprintf_chk (int flag, const char *format, va_list ap)
 
   _IO_acquire_lock (stdout);
   if (flag > 0)
-    stdout->_flags2 |= _IO_FLAGS2_CHECK_PERCENT_N;
+    stdout->_flags2 |= _IO_FLAGS2_FORTIFY;
 
   done = vfprintf (stdout, format, ap);
 
   if (flag > 0)
-    stdout->_flags2 &= ~_IO_FLAGS2_CHECK_PERCENT_N;
+    stdout->_flags2 &= ~_IO_FLAGS2_FORTIFY;
   _IO_release_lock (stdout);
 
   return done;
diff --git a/debug/vsnprintf_chk.c b/debug/vsnprintf_chk.c
index 850cd5af5a..a0fd4ebfdc 100644
--- a/debug/vsnprintf_chk.c
+++ b/debug/vsnprintf_chk.c
@@ -58,7 +58,7 @@ __vsnprintf_chk (char *s, size_t maxlen, int flags, size_t slen,
   /* For flags > 0 (i.e. __USE_FORTIFY_LEVEL > 1) request that %n
      can only come from read-only format strings.  */
   if (flags > 0)
-    sf.f._sbf._f._flags2 |= _IO_FLAGS2_CHECK_PERCENT_N;
+    sf.f._sbf._f._flags2 |= _IO_FLAGS2_FORTIFY;
 
   _IO_str_init_static_internal (&sf.f, s, maxlen - 1, s);
   ret = INTUSE(_IO_vfprintf) ((_IO_FILE *) &sf.f._sbf, format, args);
diff --git a/debug/vsprintf_chk.c b/debug/vsprintf_chk.c
index 83383286da..f41c5fc64b 100644
--- a/debug/vsprintf_chk.c
+++ b/debug/vsprintf_chk.c
@@ -81,7 +81,7 @@ __vsprintf_chk (char *s, int flags, size_t slen, const char *format,
   /* For flags > 0 (i.e. __USE_FORTIFY_LEVEL > 1) request that %n
      can only come from read-only format strings.  */
   if (flags > 0)
-    f._sbf._f._flags2 |= _IO_FLAGS2_CHECK_PERCENT_N;
+    f._sbf._f._flags2 |= _IO_FLAGS2_FORTIFY;
 
   ret = INTUSE(_IO_vfprintf) ((_IO_FILE *) &f._sbf, format, args);