about summary refs log tree commit diff
path: root/libio
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-05-06 10:56:25 -0600
committerMartin Sebor <msebor@redhat.com>2021-05-06 11:01:05 -0600
commit26492c0a14966c32c43cd6ca1d0dca5e62c6cfef (patch)
tree1d2aceda8438c17113e02f86f2c8c31d58ac7f79 /libio
parent3f0808ef4c872afeade0e323c024ac59ec90fc2b (diff)
downloadglibc-26492c0a14966c32c43cd6ca1d0dca5e62c6cfef.tar.gz
glibc-26492c0a14966c32c43cd6ca1d0dca5e62c6cfef.tar.xz
glibc-26492c0a14966c32c43cd6ca1d0dca5e62c6cfef.zip
Annotate additional APIs with GCC attribute access.
This change continues the improvements to compile-time out of bounds
checking by decorating more APIs with either attribute access, or by
explicitly providing the array bound in APIs such as tmpnam() that
expect arrays of some minimum size as arguments.  (The latter feature
is new in GCC 11.)

The only effects of the attribute and/or the array bound is to check
and diagnose calls to the functions that fail to provide a sufficient
number of elements, and the definitions of the functions that access
elements outside the specified bounds.  (There is no interplay with
_FORTIFY_SOURCE here yet.)

Tested with GCC 7 through 11 on x86_64-linux.
Diffstat (limited to 'libio')
-rw-r--r--libio/stdio.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/libio/stdio.h b/libio/stdio.h
index 144137cf67..76bda3728e 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -184,12 +184,12 @@ extern FILE *tmpfile64 (void) __wur;
 #endif
 
 /* Generate a temporary filename.  */
-extern char *tmpnam (char *__s) __THROW __wur;
+extern char *tmpnam (char[L_tmpnam]) __THROW __wur;
 
 #ifdef __USE_MISC
 /* This is the reentrant variant of `tmpnam'.  The only difference is
    that it does not allow S to be NULL.  */
-extern char *tmpnam_r (char *__s) __THROW __wur;
+extern char *tmpnam_r (char __s[L_tmpnam]) __THROW __wur;
 #endif
 
 
@@ -808,13 +808,15 @@ extern int pclose (FILE *__stream);
 
 #ifdef	__USE_POSIX
 /* Return the name of the controlling terminal.  */
-extern char *ctermid (char *__s) __THROW;
+extern char *ctermid (char *__s) __THROW
+  __attr_access ((__write_only__, 1));
 #endif /* Use POSIX.  */
 
 
 #if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU
 /* Return the name of the current user.  */
-extern char *cuserid (char *__s);
+extern char *cuserid (char *__s)
+  __attr_access ((__write_only__, 1));
 #endif /* Use X/Open, but not issue 6.  */