--- /auto/zeus/steve/cvs/wirex/immunix/StackGuard/glibc-2.2/stdio/stdio.h	Tue Apr 23 21:19:16 2002
+++ glibc-2.2.save/stdio/stdio.h	Wed Sep  5 16:17:11 2001
@@ -867,17 +867,37 @@
 			     x90,x91,x92,x93,x94,x95,x96,x97,x98,x99,      \
 			     n,ys...)  n
 
-#define printf(x...)    \
-  __protected_printf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1 , ## x)
-#define fprintf(stream, x...)  \
-  __protected_fprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1,  \
-		       stream , ## x)
-#define sprintf(string, x...)  \
-  __protected_sprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1,  \
-		       string , ## x)
-#define snprintf(string, size, x...)   \
-  __protected_snprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1 , \
-		        string, size , ## x)
+/* Need these for logging */
+#include <syslog.h>
+#include <printf.h>
+extern char *__progname;
+
+#define __formatguard_error(function_name, format)  \
+	 (openlog(__progname, LOG_PID|LOG_PERROR, LOG_KERN), \
+	 (syslog)(1, "ImmunixOS format error - mismatch of %d in %s called by %s\n", __formatguard_counter(format , ## y) - 1, function_name, __PRETTY_FUNCTION__),     \
+	 closelog(), \
+	 _exit(777), \
+	 -1 ) 
+
+#define printf(format, y...)              \
+	(__formatguard_counter(format , ##y) - 1 <= parse_printf_format (format, 0, NULL)        \
+	 ? (printf)(format , ## y)  \
+	 : __formatguard_error ("printf", format))
+
+#define fprintf(stream, format, y...)              \
+	(__formatguard_counter(format , ##y) - 1 <= parse_printf_format (format, 0, NULL)        \
+	 ? (fprintf)(stream, format , ## y)  \
+	 : __formatguard_error ("fprintf", format))
+
+#define sprintf(string, format, y...)              \
+	(__formatguard_counter(format , ##y) - 1 <= parse_printf_format (format, 0, NULL)        \
+	 ? (sprintf)(string, format , ## y)  \
+	 : __formatguard_error ("sprintf", format))
+
+#define snprintf(string, size, format, y...)              \
+	(__formatguard_counter(format , ##y) - 1 <= parse_printf_format (format, 0, NULL)        \
+	 ? (sprintf)(string, format , ## y)  \
+	 : __formatguard_error ("snprintf", format))
 
 #endif /* __FEAR_OF_A_FORMAT_GUARDED_PLANET__ */
 #endif /* __NO_FORMATGUARD_  */
--- /auto/zeus/steve/cvs/wirex/immunix/StackGuard/glibc-2.2/libio/stdio.h	Tue Apr 23 21:19:11 2002
+++ glibc-2.2.save/libio/stdio.h	Wed Sep  5 16:17:06 2001
@@ -686,17 +686,37 @@
 			     x90,x91,x92,x93,x94,x95,x96,x97,x98,x99,      \
 			     n,ys...)  n
 
-#define printf(x...)    \
-  __protected_printf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1 , ## x)
-#define fprintf(stream, x...)  \
-  __protected_fprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1,  \
-		       stream , ## x)
-#define sprintf(string, x...)  \
-  __protected_sprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1,  \
-		       string , ## x)
-#define snprintf(string, size, x...)   \
-  __protected_snprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1, \
-		        string, size , ## x)
+/* Need these for logging */
+#include <syslog.h>
+#include <printf.h>
+extern char *__progname;
+
+#define __formatguard_error(function_name, format)  \
+	 (openlog(__progname, LOG_PID|LOG_PERROR, LOG_KERN), \
+	 (syslog)(1, "ImmunixOS format error - mismatch of %d in %s called by %s\n", __formatguard_counter(format , ## y) - 1, function_name, __PRETTY_FUNCTION__),     \
+	 closelog(), \
+	 _exit(777), \
+	 -1 ) 
+
+#define printf(format, y...)              \
+	(__formatguard_counter(format , ##y) - 1 <= parse_printf_format (format, 0, NULL)        \
+	 ? (printf)(format , ## y)  \
+	 : __formatguard_error ("printf", format))
+
+#define fprintf(stream, format, y...)              \
+	(__formatguard_counter(format , ##y) - 1 <= parse_printf_format (format, 0, NULL)        \
+	 ? (fprintf)(stream, format , ## y)  \
+	 : __formatguard_error ("fprintf", format))
+
+#define sprintf(string, format, y...)              \
+	(__formatguard_counter(format , ##y) - 1 <= parse_printf_format (format, 0, NULL)        \
+	 ? (sprintf)(string, format , ## y)  \
+	 : __formatguard_error ("sprintf", format))
+
+#define snprintf(string, size, format, y...)              \
+	(__formatguard_counter(format , ##y) - 1 <= parse_printf_format (format, 0, NULL)        \
+	 ? (sprintf)(string, format , ## y)  \
+	 : __formatguard_error ("snprintf", format))
 
 #endif /* __FEAR_OF_A_FORMAT_GUARDED_PLANET__ */
 #endif /* __NO_FORMATGUARD_  */
