[uClibc-cvs] svn commit: trunk/uClibc/libc/sysdeps/linux/common

vapier at uclibc.org vapier at uclibc.org
Fri May 27 22:09:41 UTC 2005


Author: vapier
Date: 2005-05-27 16:09:40 -0600 (Fri, 27 May 2005)
New Revision: 10423

Log:
touchup defines so that we can use same ssp.c in both glibc and uclibc

Modified:
   trunk/uClibc/libc/sysdeps/linux/common/ssp.c


Changeset:
Modified: trunk/uClibc/libc/sysdeps/linux/common/ssp.c
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/common/ssp.c	2005-05-27 19:46:34 UTC (rev 10422)
+++ trunk/uClibc/libc/sysdeps/linux/common/ssp.c	2005-05-27 22:09:40 UTC (rev 10423)
@@ -21,7 +21,7 @@
 #endif
 
 #ifdef __SSP__
-#error ssp.c has to be built w/ -fno-stack-protector
+# error ssp.c has to be built w/ -fno-stack-protector
 #endif
 
 #include <stdio.h>
@@ -45,13 +45,23 @@
 # define SSP_SIGTYPE SIGABRT
 #endif
 
-/* prototypes */
-extern int __libc_open (__const char *file, int oflag, ...);
+unsigned long __guard = 0UL;
+
+/* Use of __* functions from the rest of glibc here avoids
+ * initialisation problems for executables preloaded with
+ * libraries that overload the associated standard library
+ * functions.
+ */
+#ifdef __UCLIBC__
+extern int __libc_open(__const char *file, int flags, ...);
 extern ssize_t __libc_read(int fd, void *buf, size_t count);
-extern int __libc_close (int fd);
+extern int __libc_close(int fd);
+#else
+# define __libc_open(file, flags) __open(file, flags)
+# define __libc_read(fd, buf, count) __read(fd, buf, count)
+# define __libc_close(fd) __close(fd)
+#endif
 
-unsigned long __guard = 0UL;
-
 void __guard_setup(void) __attribute__ ((constructor));
 void __guard_setup(void)
 {
@@ -66,16 +76,18 @@
 
 #ifndef __SSP_QUICK_CANARY__
 # ifdef __SSP_USE_ERANDOM__
-	int mib[3];
-	/* Random is another depth in Linux, hence an array of 3. */
-	mib[0] = CTL_KERN;
-	mib[1] = KERN_RANDOM;
-	mib[2] = RANDOM_ERANDOM;
+	{
+		int mib[3];
+		/* Random is another depth in Linux, hence an array of 3. */
+		mib[0] = CTL_KERN;
+		mib[1] = KERN_RANDOM;
+		mib[2] = RANDOM_ERANDOM;
 
-	size = sizeof(unsigned long);
-	if (__sysctl(mib, 3, &__guard, &size, NULL, 0) != (-1))
-		if (__guard != 0UL)
-			return;
+		size = sizeof(unsigned long);
+		if (__sysctl(mib, 3, &__guard, &size, NULL, 0) != (-1))
+			if (__guard != 0UL)
+				return;
+	}
 # endif /* ifdef __SSP_USE_ERANDOM__ */
 	/* 
 	 * Attempt to open kernel pseudo random device if one exists before 




More information about the uClibc-cvs mailing list