2015-03-11 18:55:51 +00:00
|
|
|
#ifndef _FORTIFY_UNISTD_H
|
|
|
|
#define _FORTIFY_UNISTD_H
|
2015-01-29 20:31:30 +00:00
|
|
|
|
|
|
|
#include_next <unistd.h>
|
|
|
|
|
|
|
|
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
|
|
|
|
|
2015-03-13 23:09:15 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-03-13 11:00:46 +00:00
|
|
|
#undef confstr
|
|
|
|
#undef getcwd
|
|
|
|
#undef getgroups
|
|
|
|
#undef gethostname
|
|
|
|
#undef getlogin_r
|
|
|
|
#undef pread
|
|
|
|
#undef read
|
|
|
|
#undef readlink
|
|
|
|
#undef readlinkat
|
|
|
|
#undef ttyname_r
|
|
|
|
#undef write
|
2015-03-11 09:26:11 +00:00
|
|
|
|
2015-03-14 19:06:48 +00:00
|
|
|
__typeof__(confstr) __confstr_orig __asm__(__USER_LABEL_PREFIX__ "confstr");
|
2015-03-14 09:38:11 +00:00
|
|
|
extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
2015-03-13 11:00:46 +00:00
|
|
|
size_t confstr(int name, char *buf, size_t len)
|
2015-02-05 14:03:53 +00:00
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(buf, 0);
|
|
|
|
|
|
|
|
if (len > bos)
|
|
|
|
__builtin_trap();
|
2015-03-13 11:00:46 +00:00
|
|
|
return __confstr_orig(name, buf, len);
|
2015-02-05 14:03:53 +00:00
|
|
|
}
|
|
|
|
|
2015-03-14 19:06:48 +00:00
|
|
|
__typeof__(getcwd) __getcwd_orig __asm__(__USER_LABEL_PREFIX__ "getcwd");
|
2015-03-14 09:38:11 +00:00
|
|
|
extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
2015-03-13 11:00:46 +00:00
|
|
|
char *getcwd(char *buf, size_t len)
|
2015-02-05 14:07:14 +00:00
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(buf, 0);
|
|
|
|
|
|
|
|
if (len > bos)
|
|
|
|
__builtin_trap();
|
2015-03-13 11:00:46 +00:00
|
|
|
return __getcwd_orig(buf, len);
|
2015-02-05 14:07:14 +00:00
|
|
|
}
|
|
|
|
|
2015-02-28 11:52:02 +00:00
|
|
|
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
2015-03-13 11:00:46 +00:00
|
|
|
#undef getdomainname
|
2015-03-14 19:06:48 +00:00
|
|
|
__typeof__(getdomainname) __getdomainname_orig __asm__(__USER_LABEL_PREFIX__ "getdomainname");
|
2015-03-14 09:38:11 +00:00
|
|
|
extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
2015-03-13 11:00:46 +00:00
|
|
|
int getdomainname(char *name, size_t len)
|
2015-02-28 11:52:02 +00:00
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(name, 0);
|
|
|
|
|
|
|
|
if (len > bos)
|
|
|
|
__builtin_trap();
|
2015-03-13 11:00:46 +00:00
|
|
|
return __getdomainname_orig(name, len);
|
2015-02-28 11:52:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-03-14 19:06:48 +00:00
|
|
|
__typeof__(getgroups) __getgroups_orig __asm__(__USER_LABEL_PREFIX__ "getgroups");
|
2015-03-14 09:38:11 +00:00
|
|
|
extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
2015-03-13 11:00:46 +00:00
|
|
|
int getgroups(int len, gid_t *set)
|
2015-02-28 12:00:25 +00:00
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(set, 0);
|
|
|
|
|
2015-02-28 20:49:00 +00:00
|
|
|
if (len > bos / sizeof(gid_t))
|
2015-02-28 12:00:25 +00:00
|
|
|
__builtin_trap();
|
2015-03-13 11:00:46 +00:00
|
|
|
return __getgroups_orig(len, set);
|
2015-02-28 12:00:25 +00:00
|
|
|
}
|
|
|
|
|
2015-03-14 19:06:48 +00:00
|
|
|
__typeof__(gethostname) __gethostname_orig __asm__(__USER_LABEL_PREFIX__ "gethostname");
|
2015-03-14 09:38:11 +00:00
|
|
|
extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
2015-03-13 11:00:46 +00:00
|
|
|
int gethostname(char *name, size_t len)
|
2015-02-23 10:45:20 +00:00
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(name, 0);
|
|
|
|
|
|
|
|
if (len > bos)
|
|
|
|
__builtin_trap();
|
2015-03-13 11:00:46 +00:00
|
|
|
return __gethostname_orig(name, len);
|
2015-02-23 10:45:20 +00:00
|
|
|
}
|
|
|
|
|
2015-03-14 19:06:48 +00:00
|
|
|
__typeof__(getlogin_r) __getlogin_r_orig __asm__(__USER_LABEL_PREFIX__ "getlogin_r");
|
2015-03-14 09:38:11 +00:00
|
|
|
extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
2015-03-13 11:00:46 +00:00
|
|
|
int getlogin_r(char *name, size_t len)
|
2015-02-25 10:31:30 +00:00
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(name, 0);
|
|
|
|
|
|
|
|
if (len > bos)
|
|
|
|
__builtin_trap();
|
2015-03-13 11:00:46 +00:00
|
|
|
return __getlogin_r_orig(name, len);
|
2015-02-25 10:31:30 +00:00
|
|
|
}
|
|
|
|
|
2015-03-14 19:06:48 +00:00
|
|
|
__typeof__(pread) __pread_orig __asm__(__USER_LABEL_PREFIX__ "pread");
|
2015-03-14 09:38:11 +00:00
|
|
|
extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
2015-03-13 11:00:46 +00:00
|
|
|
ssize_t pread(int fd, void *buf, size_t n, off_t offset)
|
2015-01-30 09:44:49 +00:00
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(buf, 0);
|
|
|
|
|
|
|
|
if (n > bos)
|
|
|
|
__builtin_trap();
|
2015-03-13 11:00:46 +00:00
|
|
|
return __pread_orig(fd, buf, n, offset);
|
2015-01-30 09:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-03-14 19:06:48 +00:00
|
|
|
__typeof__(read) __read_orig __asm__(__USER_LABEL_PREFIX__ "read");
|
2015-03-14 09:38:11 +00:00
|
|
|
extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
2015-03-13 11:00:46 +00:00
|
|
|
ssize_t read(int fd, void *buf, size_t n)
|
2015-01-29 20:31:30 +00:00
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(buf, 0);
|
|
|
|
|
|
|
|
if (n > bos)
|
|
|
|
__builtin_trap();
|
2015-03-13 11:00:46 +00:00
|
|
|
return __read_orig(fd, buf, n);
|
2015-01-29 20:31:30 +00:00
|
|
|
}
|
|
|
|
|
2015-03-14 19:06:48 +00:00
|
|
|
__typeof__(readlink) __readlink_orig __asm__(__USER_LABEL_PREFIX__ "readlink");
|
2015-03-14 09:38:11 +00:00
|
|
|
extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
2015-03-13 11:00:46 +00:00
|
|
|
ssize_t readlink(const char *path, char *buf, size_t n)
|
2015-02-28 16:48:58 +00:00
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(buf, 0);
|
|
|
|
|
|
|
|
if (n > bos)
|
|
|
|
__builtin_trap();
|
2015-03-13 11:00:46 +00:00
|
|
|
return __readlink_orig(path, buf, n);
|
2015-02-28 16:48:58 +00:00
|
|
|
}
|
|
|
|
|
2015-03-14 19:06:48 +00:00
|
|
|
__typeof__(readlinkat) __readlinkat_orig __asm__(__USER_LABEL_PREFIX__ "readlinkat");
|
2015-03-14 09:38:11 +00:00
|
|
|
extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
2015-03-13 11:00:46 +00:00
|
|
|
ssize_t readlinkat(int fd, const char *path, char *buf, size_t n)
|
2015-02-28 16:48:58 +00:00
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(buf, 0);
|
|
|
|
|
|
|
|
if (n > bos)
|
|
|
|
__builtin_trap();
|
2015-03-13 11:00:46 +00:00
|
|
|
return __readlinkat_orig(fd, path, buf, n);
|
2015-02-28 16:48:58 +00:00
|
|
|
}
|
|
|
|
|
2015-03-14 19:06:48 +00:00
|
|
|
__typeof__(ttyname_r) __ttyname_r_orig __asm__(__USER_LABEL_PREFIX__ "ttyname_r");
|
2015-03-14 09:38:11 +00:00
|
|
|
extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
2015-03-13 11:00:46 +00:00
|
|
|
int ttyname_r(int fd, char *name, size_t n)
|
2015-02-28 15:30:25 +00:00
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(name, 0);
|
|
|
|
|
|
|
|
if (n > bos)
|
|
|
|
__builtin_trap();
|
2015-03-13 11:00:46 +00:00
|
|
|
return __ttyname_r_orig(fd, name, n);
|
2015-02-28 15:30:25 +00:00
|
|
|
}
|
|
|
|
|
2015-03-14 19:06:48 +00:00
|
|
|
__typeof__(write) __write_orig __asm__(__USER_LABEL_PREFIX__ "write");
|
2015-03-14 09:38:11 +00:00
|
|
|
extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
2015-03-13 11:00:46 +00:00
|
|
|
ssize_t write(int fd, const void *buf, size_t n)
|
2015-02-24 19:34:37 +00:00
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(buf, 0);
|
|
|
|
|
|
|
|
if (n > bos)
|
|
|
|
__builtin_trap();
|
2015-03-13 11:00:46 +00:00
|
|
|
return __write_orig(fd, buf, n);
|
2015-02-24 19:34:37 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 23:09:15 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2015-03-11 09:26:11 +00:00
|
|
|
#endif
|
|
|
|
|
2015-01-29 20:31:30 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|