1feee8
commit a4217408a3d6050a7f42ac23adb6ac7218dca85f
1feee8
Author: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
1feee8
Date:   Fri Nov 11 17:00:15 2022 -0300
1feee8
1feee8
    Apply asm redirections in syslog.h before first use [BZ #27087]
1feee8
    
1feee8
    Similar to d0fa09a770, but for syslog.h when _FORTIFY_SOURCE > 0.
1feee8
    Fixes [BZ #27087] by applying long double-related asm redirections
1feee8
    before using functions in bits/syslog.h.
1feee8
    
1feee8
    Tested with build-many-glibcs.py.
1feee8
    
1feee8
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
1feee8
    (cherry picked from commit 227df6243a2b5b4d70d11772d12c02eb9cb666ca)
1feee8
1feee8
diff --git a/misc/bits/syslog.h b/misc/bits/syslog.h
1feee8
index 6f3137a98ee593f3..10c9c1151382a51c 100644
1feee8
--- a/misc/bits/syslog.h
1feee8
+++ b/misc/bits/syslog.h
1feee8
@@ -24,6 +24,20 @@
1feee8
 extern void __syslog_chk (int __pri, int __flag, const char *__fmt, ...)
1feee8
      __attribute__ ((__format__ (__printf__, 3, 4)));
1feee8
 
1feee8
+#ifdef __USE_MISC
1feee8
+extern void __vsyslog_chk (int __pri, int __flag, const char *__fmt,
1feee8
+			   __gnuc_va_list __ap)
1feee8
+     __attribute__ ((__format__ (__printf__, 3, 0)));
1feee8
+#endif
1feee8
+
1feee8
+#include <bits/floatn.h>
1feee8
+#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
1feee8
+# include <bits/syslog-ldbl.h>
1feee8
+#endif
1feee8
+
1feee8
+/* The following functions must be used only after applying all asm
1feee8
+   redirections, e.g. long double asm redirections.  */
1feee8
+
1feee8
 #ifdef __va_arg_pack
1feee8
 __fortify_function void
1feee8
 syslog (int __pri, const char *__fmt, ...)
1feee8
@@ -37,10 +51,6 @@ syslog (int __pri, const char *__fmt, ...)
1feee8
 
1feee8
 
1feee8
 #ifdef __USE_MISC
1feee8
-extern void __vsyslog_chk (int __pri, int __flag, const char *__fmt,
1feee8
-			   __gnuc_va_list __ap)
1feee8
-     __attribute__ ((__format__ (__printf__, 3, 0)));
1feee8
-
1feee8
 __fortify_function void
1feee8
 vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap)
1feee8
 {
1feee8
diff --git a/misc/sys/syslog.h b/misc/sys/syslog.h
1feee8
index dc3b0e7ef81de812..e7a98fb9b13ce132 100644
1feee8
--- a/misc/sys/syslog.h
1feee8
+++ b/misc/sys/syslog.h
1feee8
@@ -205,11 +205,11 @@ extern void vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap)
1feee8
 /* Define some macros helping to catch buffer overflows.  */
1feee8
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
1feee8
 # include <bits/syslog.h>
1feee8
-#endif
1feee8
-
1feee8
-#include <bits/floatn.h>
1feee8
-#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
1feee8
-# include <bits/syslog-ldbl.h>
1feee8
+#else
1feee8
+# include <bits/floatn.h>
1feee8
+# if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
1feee8
+#  include <bits/syslog-ldbl.h>
1feee8
+# endif
1feee8
 #endif
1feee8
 
1feee8
 __END_DECLS