Backport: Identify unsafe macros in the glibc documentation.

Resolves: RHEL-46740
This commit is contained in:
Frédéric Bérat 2025-01-08 17:20:47 +01:00
parent 513884a413
commit fe757a315a
2 changed files with 60 additions and 0 deletions

58
glibc-RHEL-46740.patch Normal file
View File

@ -0,0 +1,58 @@
commit dcad78507433a9a64b8b548b19e110933f8d939a
Author: DJ Delorie <dj@redhat.com>
Date: Thu Oct 10 17:16:35 2024 -0400
manual: Document stdio.h functions that may be macros
Glibc has two gnu-extension functions that are implemented as
macros but not documented as such: fread_unlocked and
fwrite_unlocked. Document them as such.
Additionally, putc_unlocked and getc_unlocked are documented in
POSIX as possibly being macros. Update the manual to add a warning
about those also, depite glibc not implementing them as macros.
diff --git a/manual/stdio.texi b/manual/stdio.texi
index 98da13de32f49c7c..01fa2d0ffdbd6f5f 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -929,6 +929,9 @@ Therefore, @var{stream} should never be an expression with side-effects.
@safety{@prelim{}@mtsafe{@mtsrace{:stream}}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
The @code{putc_unlocked} function is equivalent to the @code{putc}
function except that it does not implicitly lock the stream.
+Like @code{putc}, it may be implemented as a macro and may evaluate
+the @var{stream} argument more than once. Therefore, @var{stream}
+should not be an expression with side-effects.
@end deftypefun
@deftypefun wint_t putwc_unlocked (wchar_t @var{wc}, FILE *@var{stream})
@@ -1132,6 +1135,9 @@ Therefore, @var{stream} should never be an expression with side-effects.
@safety{@prelim{}@mtsafe{@mtsrace{:stream}}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
The @code{getc_unlocked} function is equivalent to the @code{getc}
function except that it does not implicitly lock the stream.
+Like @code{getc}, it may be implemented as a macro and may evaluate
+the @var{stream} argument more than once. Therefore, @var{stream}
+should not be an expression with side-effects.
@end deftypefun
@deftypefun wint_t getwc_unlocked (FILE *@var{stream})
@@ -1571,6 +1577,9 @@ The @code{fread_unlocked} function is equivalent to the @code{fread}
function except that it does not implicitly lock the stream.
This function is a GNU extension.
+This function may be implemented as a macro and may evaluate
+@var{stream} more than once. Therefore, @var{stream} should not be an
+expression with side-effects.
@end deftypefun
@deftypefun size_t fwrite (const void *@var{data}, size_t @var{size}, size_t @var{count}, FILE *@var{stream})
@@ -1589,6 +1598,9 @@ The @code{fwrite_unlocked} function is equivalent to the @code{fwrite}
function except that it does not implicitly lock the stream.
This function is a GNU extension.
+This function may be implemented as a macro and may evaluate
+@var{stream} more than once. Therefore, @var{stream} should not be an
+expression with side-effects.
@end deftypefun
@node Formatted Output

View File

@ -1043,6 +1043,7 @@ Patch735: glibc-RHEL-56540-1.patch
Patch736: glibc-RHEL-56540-2.patch
Patch737: glibc-RHEL-56540-3.patch
Patch738: glibc-RHEL-58671.patch
Patch739: glibc-RHEL-46740.patch
##############################################################################
# Continued list of core "glibc" package information:
@ -3048,6 +3049,7 @@ update_gconv_modules_cache ()
- Backport test implementation to verify rewinddir behavior
(RHEL-56540)
- Backport elf/tst-startup-errno test (RHEL-58671)
- Backport: Identify unsafe macros in the glibc documentation (RHEL-46740)
* Thu Dec 19 2024 DJ Delorie <dj@redhat.com> - 2.34-148
- Increase ungetc test coverage, guarantee single char pushback (RHEL-46738)