fortify-headers/include/unistd.h

143 lines
2.8 KiB
C
Raw Normal View History

#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
#include "fortify-headers.h"
2015-01-29 20:31:30 +00:00
2015-03-13 23:09:15 +00:00
#ifdef __cplusplus
extern "C" {
#endif
#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
fortify_fn(confstr) 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();
return __orig_confstr(name, buf, len);
2015-02-05 14:03:53 +00:00
}
fortify_fn(getcwd) 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();
return __orig_getcwd(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)
#undef getdomainname
fortify_fn(getdomainname) 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();
return __orig_getdomainname(name, len);
2015-02-28 11:52:02 +00:00
}
#endif
fortify_fn(getgroups) int getgroups(int len, gid_t *set)
{
size_t bos = __builtin_object_size(set, 0);
if (len > bos / sizeof(gid_t))
__builtin_trap();
return __orig_getgroups(len, set);
}
fortify_fn(gethostname) 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();
return __orig_gethostname(name, len);
2015-02-23 10:45:20 +00:00
}
fortify_fn(getlogin_r) 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();
return __orig_getlogin_r(name, len);
2015-02-25 10:31:30 +00:00
}
fortify_fn(pread) 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();
return __orig_pread(fd, buf, n, offset);
2015-01-30 09:44:49 +00:00
}
fortify_fn(read) 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();
return __orig_read(fd, buf, n);
2015-01-29 20:31:30 +00:00
}
fortify_fn(readlink) 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();
return __orig_readlink(path, buf, n);
2015-02-28 16:48:58 +00:00
}
fortify_fn(readlinkat) 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();
return __orig_readlinkat(fd, path, buf, n);
2015-02-28 16:48:58 +00:00
}
fortify_fn(ttyname_r) 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();
return __orig_ttyname_r(fd, name, n);
2015-02-28 15:30:25 +00:00
}
fortify_fn(write) 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();
return __orig_write(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