summaryrefslogtreecommitdiff
path: root/include/unistd.h
diff options
context:
space:
mode:
authorsin2015-01-30 16:37:07 +0000
committersin2015-01-30 16:37:07 +0000
commit6156f7de8beff23762b207c02e5e96ac75b51a5c (patch)
tree2f428e44dffcf38a74cf67d00af4b6228ada1c1f /include/unistd.h
parentfcec6e8280b6bcbaa915afd43c6ca552ccec4e87 (diff)
Remove pwrite/write
Diffstat (limited to 'include/unistd.h')
-rw-r--r--include/unistd.h34
1 files changed, 0 insertions, 34 deletions
diff --git a/include/unistd.h b/include/unistd.h
index 205e31c..e4358a0 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -23,21 +23,6 @@ __fortify_pread(int fd, void *buf, size_t n, off_t offset)
23 return pread(fd, buf, n, offset); 23 return pread(fd, buf, n, offset);
24} 24}
25 25
26__errordecl(__pwrite_error, "pwrite: buffer overflow detected");
27static inline __attribute__ ((always_inline))
28ssize_t
29__fortify_pwrite(int fd, void *buf, size_t n, off_t offset)
30{
31 size_t bos = __builtin_object_size(buf, 0);
32
33 if (__builtin_constant_p(n) && n > bos)
34 __pwrite_error();
35
36 if (n > bos)
37 __builtin_trap();
38 return pwrite(fd, buf, n, offset);
39}
40
41__errordecl(__read_error, "read: buffer overflow detected"); 26__errordecl(__read_error, "read: buffer overflow detected");
42static inline __attribute__ ((always_inline)) 27static inline __attribute__ ((always_inline))
43ssize_t 28ssize_t
@@ -53,29 +38,10 @@ __fortify_read(int fd, void *buf, size_t n)
53 return read(fd, buf, n); 38 return read(fd, buf, n);
54} 39}
55 40
56__errordecl(__write_error, "write: buffer overflow detected");
57static inline __attribute__ ((always_inline))
58ssize_t
59__fortify_write(int fd, void *buf, size_t n)
60{
61 size_t bos = __builtin_object_size(buf, 0);
62
63 if (__builtin_constant_p(n) && n > bos)
64 __write_error();
65
66 if (n > bos)
67 __builtin_trap();
68 return write(fd, buf, n);
69}
70
71#undef pread 41#undef pread
72#define pread(fd, buf, n, offset) __fortify_pread(fd, buf, n, offset) 42#define pread(fd, buf, n, offset) __fortify_pread(fd, buf, n, offset)
73#undef pwrite
74#define pwrite(fd, buf, n, offset) __fortify_pwrite(fd, buf, n, offset)
75#undef read 43#undef read
76#define read(fd, buf, n) __fortify_read(fd, buf, n) 44#define read(fd, buf, n) __fortify_read(fd, buf, n)
77#undef write
78#define write(fd, buf, n) __fortify_write(fd, buf, n)
79 45
80#endif 46#endif
81 47