Loading...
secure/snprintf_chk.c Libc-1725.40.4 Libc-583
--- Libc/Libc-1725.40.4/secure/snprintf_chk.c
+++ Libc/Libc-583/secure/snprintf_chk.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2007 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
@@ -25,42 +25,27 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <limits.h>
-#include "secure.h"
+
+extern void __chk_fail (void) __attribute__((__noreturn__));
+extern int __snprintf_chk (char * __restrict, size_t, int, size_t,
+                           const char * __restrict, ...)
+  __DARWIN_LDBL_COMPAT (__snprintf_chk);
 
 int
-__snprintf_chk (char *dest, size_t len, int flags, size_t dstlen,
+__snprintf_chk (char *s, size_t maxlen, int flags, size_t len,
 		const char *format, ...)
 {
   va_list arg;
   int done;
 
-  if (__builtin_expect (dstlen < len, 0))
-    __chk_fail_overflow ();
+  if (__builtin_expect (maxlen > len, 0))
+    __chk_fail ();
 
   va_start (arg, format);
 
-  done = vsnprintf (dest, len, format, arg);
+  done = vsnprintf (s, maxlen, format, arg);
 
   va_end (arg);
 
   return done;
 }
-
-int
-__snprintf_object_size_chk (char *dest, size_t dstlen, size_t len,
-const char *format, ...)
-{
-    va_list arg;
-    int done;
-
-    if (__builtin_expect (dstlen < len, 0))
-        __chk_fail_overflow ();
-
-    va_start (arg, format);
-
-    done = vsnprintf (dest, len, format, arg);
-
-    va_end (arg);
-
-    return done;
-}