Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F161315774
D32307.id96308.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D32307.id96308.diff
View Options
Index: contrib/netbsd-tests/lib/libc/ssp/h_gets.c
===================================================================
--- contrib/netbsd-tests/lib/libc/ssp/h_gets.c
+++ contrib/netbsd-tests/lib/libc/ssp/h_gets.c
@@ -34,6 +34,10 @@
#include <stdio.h>
#ifdef __FreeBSD__
+#ifdef _FORTIFY_SOURCE
+#undef gets
+#endif
+
/*
* We want to test the gets() implementation, but cannot simply link against
* the gets symbol because it is not in the default version. (We've made it
Index: include/ssp/test.h
===================================================================
--- /dev/null
+++ include/ssp/test.h
@@ -0,0 +1,4 @@
+#define _FORTIFY_SOURCE 2
+#include "string.h"
+
+stpncpy(1, 1, 1);
Index: include/ssp/unistd.h
===================================================================
--- include/ssp/unistd.h
+++ include/ssp/unistd.h
@@ -36,8 +36,12 @@
#if __SSP_FORTIFY_LEVEL > 0
__BEGIN_DECLS
-__ssp_redirect0(ssize_t, read, (int __fd, void *__buf, size_t __len), \
- (__fd, __buf, __len));
+#ifndef _FORTIFY_SOURCE_read
+#define _FORTIFY_SOURCE_read read
+#endif
+
+__ssp_redirect0(ssize_t, _FORTIFY_SOURCE_read, (int __fd, void *__buf,
+ size_t __len), (__fd, __buf, __len));
__ssp_redirect(ssize_t, readlink, (const char *__restrict __path, \
char *__restrict __buf, size_t __len), (__path, __buf, __len));
Index: lib/libc/Makefile
===================================================================
--- lib/libc/Makefile
+++ lib/libc/Makefile
@@ -21,6 +21,8 @@
LIBC_ARCH=${MACHINE_CPUARCH}
.endif
+CFLAGS+=-D_FORTIFY_SOURCE_read=_read
+
# All library objects contain FreeBSD revision strings by default; they may be
# excluded as a space-saving measure. To produce a library that does
# not contain these strings, add -DSTRIP_FBSDID (see <sys/cdefs.h>) to CFLAGS
Index: lib/libc/amd64/string/bcopy.c
===================================================================
--- lib/libc/amd64/string/bcopy.c
+++ lib/libc/amd64/string/bcopy.c
@@ -8,7 +8,7 @@
#include <string.h>
void
-bcopy(const void *src, void *dst, size_t len)
+(bcopy)(const void *src, void *dst, size_t len)
{
memmove(dst, src, len);
Index: lib/libc/amd64/string/bzero.c
===================================================================
--- lib/libc/amd64/string/bzero.c
+++ lib/libc/amd64/string/bzero.c
@@ -8,7 +8,7 @@
#include <string.h>
void
-bzero(void *b, size_t len)
+(bzero)(void *b, size_t len)
{
memset(b, 0, len);
Index: lib/libc/gen/getcwd.c
===================================================================
--- lib/libc/gen/getcwd.c
+++ lib/libc/gen/getcwd.c
@@ -44,6 +44,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <ssp/ssp.h>
#include "un-namespace.h"
#include "gen-private.h"
@@ -55,7 +56,7 @@
extern int __getcwd(char *, size_t);
char *
-getcwd(char *pt, size_t size)
+__ssp_real(getcwd)(char *pt, size_t size)
{
struct dirent *dp;
DIR *dir = NULL;
Index: lib/libc/stdio/fgets.c
===================================================================
--- lib/libc/stdio/fgets.c
+++ lib/libc/stdio/fgets.c
@@ -52,7 +52,7 @@
* Return first argument, or NULL if no characters were read.
*/
char *
-fgets(char * __restrict buf, int n, FILE * __restrict fp)
+(fgets)(char * __restrict buf, int n, FILE * __restrict fp)
{
size_t len;
char *s, *ret;
Index: lib/libc/stdio/snprintf.c
===================================================================
--- lib/libc/stdio/snprintf.c
+++ lib/libc/stdio/snprintf.c
@@ -52,7 +52,7 @@
#include "local.h"
int
-snprintf(char * __restrict str, size_t n, char const * __restrict fmt, ...)
+(snprintf)(char * __restrict str, size_t n, char const * __restrict fmt, ...)
{
size_t on;
int ret;
Index: lib/libc/stdio/sprintf.c
===================================================================
--- lib/libc/stdio/sprintf.c
+++ lib/libc/stdio/sprintf.c
@@ -50,7 +50,7 @@
#include "xlocale_private.h"
int
-sprintf(char * __restrict str, char const * __restrict fmt, ...)
+(sprintf)(char * __restrict str, char const * __restrict fmt, ...)
{
int ret;
va_list ap;
Index: lib/libc/stdio/vsnprintf.c
===================================================================
--- lib/libc/stdio/vsnprintf.c
+++ lib/libc/stdio/vsnprintf.c
@@ -83,7 +83,7 @@
return (ret);
}
int
-vsnprintf(char * __restrict str, size_t n, const char * __restrict fmt,
+(vsnprintf)(char * __restrict str, size_t n, const char * __restrict fmt,
__va_list ap)
{
return vsnprintf_l(str, n, __get_locale(), fmt, ap);
Index: lib/libc/stdio/vsprintf.c
===================================================================
--- lib/libc/stdio/vsprintf.c
+++ lib/libc/stdio/vsprintf.c
@@ -64,7 +64,7 @@
return (ret);
}
int
-vsprintf(char * __restrict str, const char * __restrict fmt, __va_list ap)
+(vsprintf)(char * __restrict str, const char * __restrict fmt, __va_list ap)
{
return vsprintf_l(str, __get_locale(), fmt, ap);
}
Index: lib/libc/string/bcopy.c
===================================================================
--- lib/libc/string/bcopy.c
+++ lib/libc/string/bcopy.c
@@ -55,16 +55,16 @@
void *
#ifdef MEMCOPY
-memcpy
+(memcpy)
#else
-memmove
+(memmove)
#endif
(void *dst0, const void *src0, size_t length)
#else
#include <strings.h>
void
-bcopy(const void *src0, void *dst0, size_t length)
+(bcopy)(const void *src0, void *dst0, size_t length)
#endif
{
char *dst = dst0;
Index: lib/libc/string/memset.c
===================================================================
--- lib/libc/string/memset.c
+++ lib/libc/string/memset.c
@@ -53,7 +53,7 @@
#define WIDEVAL 0
void
-bzero(void *dst0, size_t length)
+(bzero)(void *dst0, size_t length)
#else
#include <string.h>
@@ -62,7 +62,7 @@
#define WIDEVAL c
void *
-memset(void *dst0, int c0, size_t length)
+(memset)(void *dst0, int c0, size_t length)
#endif
{
size_t t;
Index: lib/libc/string/stpcpy.c
===================================================================
--- lib/libc/string/stpcpy.c
+++ lib/libc/string/stpcpy.c
@@ -40,7 +40,7 @@
#include <string.h>
char *
-stpcpy(char * __restrict to, const char * __restrict from)
+(stpcpy)(char * __restrict to, const char * __restrict from)
{
for (; (*to = *from); ++from, ++to);
Index: lib/libc/string/stpncpy.c
===================================================================
--- lib/libc/string/stpncpy.c
+++ lib/libc/string/stpncpy.c
@@ -32,7 +32,7 @@
#include <string.h>
char *
-stpncpy(char * __restrict dst, const char * __restrict src, size_t n)
+(stpncpy)(char * __restrict dst, const char * __restrict src, size_t n)
{
for (; n--; dst++, src++) {
Index: lib/libc/string/strcat.c
===================================================================
--- lib/libc/string/strcat.c
+++ lib/libc/string/strcat.c
@@ -38,7 +38,7 @@
#include <string.h>
char *
-strcat(char * __restrict s, const char * __restrict append)
+(strcat)(char * __restrict s, const char * __restrict append)
{
char *save = s;
Index: lib/libc/string/strncat.c
===================================================================
--- lib/libc/string/strncat.c
+++ lib/libc/string/strncat.c
@@ -45,7 +45,7 @@
* are written at dst (at most n+1 bytes being appended). Return dst.
*/
char *
-strncat(char * __restrict dst, const char * __restrict src, size_t n)
+(strncat)(char * __restrict dst, const char * __restrict src, size_t n)
{
if (n != 0) {
char *d = dst;
Index: lib/libc/sys/read.c
===================================================================
--- lib/libc/sys/read.c
+++ lib/libc/sys/read.c
@@ -36,6 +36,7 @@
#include <sys/types.h>
#include <sys/syscall.h>
#include <unistd.h>
+#include <ssp/ssp.h>
#include "libc_private.h"
__weak_reference(__sys_read, __read);
Index: sys/sys/cdefs.h
===================================================================
--- sys/sys/cdefs.h
+++ sys/sys/cdefs.h
@@ -631,6 +631,16 @@
#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
#endif
+#if !defined(_STANDALONE) && !defined(_KERNEL)
+#if defined(__GNUC__) || defined(__PCC__)
+#define __RENAME(x) __asm(__STRING(x))
+#else
+#error "No function renaming possible"
+#endif /* __GNUC__ */
+#else /* _STANDALONE || _KERNEL */
+#define __RENAME(x) no renaming in kernel/standalone environment
+#endif
+
/*-
* The following definitions are an extension of the behavior originally
* implemented in <sys/_posix.h>, but with a different level of granularity.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 3, 5:46 PM (14 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34632494
Default Alt Text
D32307.id96308.diff (8 KB)
Attached To
Mode
D32307: Prepare the system for _FORTIFY_SOURCE
Attached
Detach File
Event Timeline
Log In to Comment