Index: glibc-2.2/libio/stdio.h
===================================================================
RCS file: /work/cvs/wirex/immunix/StackGuard/glibc-2.2/libio/stdio.h,v
retrieving revision 1.20
diff -u -r1.20 stdio.h
--- glibc-2.2/libio/stdio.h	2001/05/10 22:00:05	1.20
+++ glibc-2.2/libio/stdio.h	2002/04/24 05:04:39
@@ -650,6 +650,9 @@
 #ifndef __NO_FORMATGUARD_ 	/* Eh?  */
 #ifndef __FEAR_OF_A_FORMAT_GUARDED_PLANET__ 		
 
+/* We must keep these around since we introduced them in glibc-2.2
+ * (ImmunixOS 7.0) - SMB */
+
 extern int __protected_printf (const char *calling, int args, 
 			       const char *format, ...);
 extern int __protected_sprintf (const char *calling, int args, char *str, 
@@ -659,6 +662,99 @@
 extern int __protected_snprintf (const char *calling, int args, char *str, 
 				 size_t size, const char *format, ...);
 
+/* Shiny new static functions so we can be compatible with glibc's
+ * that don't have our patches. - SMB */
+
+#include <stdarg.h>
+#include <syslog.h>
+#include <printf.h>
+
+#define __check_format_args(format, args, name) 			\
+  do { 									\
+    int requested_args;							\
+    int dummy;								\
+    int passed_args = (args);						\
+    extern char *__progname;						\
+    const char *death_message = "ImmunixOS format error - mismatch of %d in %s called by %s\n";		\
+									\
+    requested_args = parse_printf_format ((format), 1, &dummy);		\
+									\
+    if (passed_args < requested_args) {					\
+      openlog (__progname, LOG_PID|LOG_PERROR, LOG_KERN);		\
+      syslog (1, death_message, passed_args, (name), calling);		\
+      closelog ();							\
+      _exit (777);							\
+    }									\
+  } while (0)
+
+static int __static_protected_printf (const char *calling, int args, 
+			   const char *format, ...) __attribute__((__unused__));
+static int 
+__static_protected_printf (const char *calling, int args, 
+			   const char *format, ...)
+{
+  int ret;
+  va_list ap;
+
+  __check_format_args (format, args, "printf");
+
+  va_start (ap, format);
+  ret = vprintf (format, ap);
+  va_end (ap);
+  return ret;
+}
+
+static int __static_protected_sprintf (const char *calling, int args, char *str,
+			  const char *format, ...) __attribute__ ((__unused__));
+static int 
+__static_protected_sprintf (const char *calling, int args, char *str, 
+			    const char *format, ...)
+{
+  int ret;
+  va_list ap;
+
+  __check_format_args (format, args, "sprintf");
+
+  va_start (ap, format);
+  ret = vsprintf (str, format, ap);
+  va_end (ap);
+  return ret;
+}
+
+static int __static_protected_fprintf (const char *calling, int args, FILE *stream, 
+			  const char *format, ...) __attribute__ ((__unused__));
+static int 
+__static_protected_fprintf (const char *calling, int args, FILE *stream, 
+			    const char *format, ...)
+{
+  int ret;
+  va_list ap;
+
+  __check_format_args (format, args, "fprintf");
+
+  va_start (ap, format);
+  ret = vfprintf (stream, format, ap);
+  va_end (ap);
+  return ret;
+}
+
+static int __static_protected_snprintf (const char *calling, int args, char *str, 
+	     size_t size, const char *format, ...) __attribute__ ((__unused__));
+static int 
+__static_protected_snprintf (const char *calling, int args, char *str, 
+			     size_t size, const char *format, ...)
+{
+  int ret;
+  va_list ap;
+
+  __check_format_args (format, args, "snprintf");
+
+  va_start (ap, format);
+  ret = vsnprintf (str,size,format, ap);
+  va_end (ap);
+  return ret;
+}
+
 #undef printf
 #undef sprintf
 #undef fprintf
@@ -687,15 +783,15 @@
 			     n,ys...)  n
 
 #define printf(x...)    \
-  __protected_printf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1 , ## x)
+  __static_protected_printf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1 , ## x)
 #define fprintf(stream, x...)  \
-  __protected_fprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1,  \
+  __static_protected_fprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1,  \
 		       stream , ## x)
 #define sprintf(string, x...)  \
-  __protected_sprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1,  \
+  __static_protected_sprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1,  \
 		       string , ## x)
 #define snprintf(string, size, x...)   \
-  __protected_snprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1, \
+  __static_protected_snprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1, \
 		        string, size , ## x)
 
 #endif /* __FEAR_OF_A_FORMAT_GUARDED_PLANET__ */
Index: glibc-2.2/stdio/stdio.h
===================================================================
RCS file: /work/cvs/wirex/immunix/StackGuard/glibc-2.2/stdio/stdio.h,v
retrieving revision 1.21
diff -u -r1.21 stdio.h
--- glibc-2.2/stdio/stdio.h	2001/05/10 22:00:05	1.21
+++ glibc-2.2/stdio/stdio.h	2002/04/24 05:04:40
@@ -831,6 +831,9 @@
 #ifndef __NO_FORMATGUARD_  /* The Man is trying to keep me down! */
 #ifndef __FEAR_OF_A_FORMAT_GUARDED_PLANET__
 
+/* We must keep these around since we introduced them in glibc-2.2
+ * (ImmunixOS 7.0) - SMB */
+
 extern int __protected_printf (const char *calling, int args, 
 			       const char *format, ...);
 extern int __protected_sprintf (const char *calling, int args, char *str, 
@@ -840,6 +843,99 @@
 extern int __protected_snprintf (const char *calling, int args, char *str, 
 				 size_t size, const char *format, ...);
 
+/* Shiny new static inline functions so we can be compatible with glibc's
+ * that don't have our patches. - SMB */
+
+#include <stdarg.h>
+#include <syslog.h>
+#include <printf.h>
+
+#define __check_format_args(format, args, name) 			\
+  do { 									\
+    int requested_args;							\
+    int dummy;								\
+    int passed_args = (args);						\
+    extern char *__progname;						\
+    const char *death_message = "ImmunixOS format error - mismatch of %d in %s called by %s\n";		\
+									\
+    requested_args = parse_printf_format ((format), 1, &dummy);		\
+									\
+    if (passed_args < requested_args) {					\
+      openlog (__progname, LOG_PID|LOG_PERROR, LOG_KERN);		\
+      syslog (1, death_message, passed_args, (name), calling);		\
+      closelog ();							\
+      _exit (777);							\
+    }									\
+  } while (0)
+
+static int __static_protected_printf (const char *calling, int args, 
+			  const char *format, ...) __attribute__ ((__unused__));
+static int 
+__static_protected_printf (const char *calling, int args, 
+			   const char *format, ...) 
+{
+  int ret;
+  va_list ap;
+
+  __check_format_args (format, args, "printf");
+
+  va_start (ap, format);
+  ret = vprintf (format, ap);
+  va_end (ap);
+  return ret;
+}
+
+static int __static_protected_sprintf (const char *calling, int args, char *str,
+			  const char *format, ...) __attribute__ ((__unused__));
+static int 
+__static_protected_sprintf (const char *calling, int args, char *str, 
+			    const char *format, ...)
+{
+  int ret;
+  va_list ap;
+
+  __check_format_args (format, args, "sprintf");
+
+  va_start (ap, format);
+  ret = vsprintf (str, format, ap);
+  va_end (ap);
+  return ret;
+}
+
+static int __static_protected_fprintf (const char *calling, int args, FILE *stream, 
+			  const char *format, ...) __attribute__ ((__unused__));
+static int 
+__static_protected_fprintf (const char *calling, int args, FILE *stream, 
+			    const char *format, ...)
+{
+  int ret;
+  va_list ap;
+
+  __check_format_args (format, args, "fprintf");
+
+  va_start (ap, format);
+  ret = vfprintf (stream, format, ap);
+  va_end (ap);
+  return ret;
+}
+
+static int __static_protected_snprintf (const char *calling, int args, char *str, 
+	     size_t size, const char *format, ...) __attribute__ ((__unused__));
+static int 
+__static_protected_snprintf (const char *calling, int args, char *str, 
+			     size_t size, const char *format, ...)
+{
+  int ret;
+  va_list ap;
+
+  __check_format_args (format, args, "snprintf");
+
+  va_start (ap, format);
+  ret = vsnprintf (str,size,format, ap);
+  va_end (ap);
+  return ret;
+}
+
 #undef printf
 #undef sprintf
 #undef fprintf
@@ -868,15 +964,15 @@
 			     n,ys...)  n
 
 #define printf(x...)    \
-  __protected_printf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1 , ## x)
+  ___static_protected_printf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1 , ## x)
 #define fprintf(stream, x...)  \
-  __protected_fprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1,  \
+  __static_protected_fprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1,  \
 		       stream , ## x)
 #define sprintf(string, x...)  \
-  __protected_sprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1,  \
+  __static_protected_sprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1,  \
 		       string , ## x)
 #define snprintf(string, size, x...)   \
-  __protected_snprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1 , \
+  __static_protected_snprintf (__PRETTY_FUNCTION__, __formatguard_counter(x) - 1 , \
 		        string, size , ## x)
 
 #endif /* __FEAR_OF_A_FORMAT_GUARDED_PLANET__ */
