add fortified implementations of write/pwrite{,64}
These are just based on the read/pread{,64} implementations with the
function calls and error messages adjusted as appropriate. The only
difference is that the buffer parameters are const.
Change-Id: Ida1597a903807f583f230d74bcedffdb7b24fcf6
This commit is contained in:
@@ -645,6 +645,22 @@ TEST_F(DEATHTEST, pread64_fortified) {
|
||||
close(fd);
|
||||
}
|
||||
|
||||
TEST_F(DEATHTEST, pwrite_fortified) {
|
||||
char buf[1] = {0};
|
||||
size_t ct = atoi("2"); // prevent optimizations
|
||||
int fd = open("/dev/null", O_WRONLY);
|
||||
ASSERT_FORTIFY(pwrite(fd, buf, ct, 0));
|
||||
close(fd);
|
||||
}
|
||||
|
||||
TEST_F(DEATHTEST, pwrite64_fortified) {
|
||||
char buf[1] = {0};
|
||||
size_t ct = atoi("2"); // prevent optimizations
|
||||
int fd = open("/dev/null", O_WRONLY);
|
||||
ASSERT_FORTIFY(pwrite64(fd, buf, ct, 0));
|
||||
close(fd);
|
||||
}
|
||||
|
||||
TEST_F(DEATHTEST, read_fortified) {
|
||||
char buf[1];
|
||||
size_t ct = atoi("2"); // prevent optimizations
|
||||
@@ -653,6 +669,14 @@ TEST_F(DEATHTEST, read_fortified) {
|
||||
close(fd);
|
||||
}
|
||||
|
||||
TEST_F(DEATHTEST, write_fortified) {
|
||||
char buf[1] = {0};
|
||||
size_t ct = atoi("2"); // prevent optimizations
|
||||
int fd = open("/dev/null", O_WRONLY);
|
||||
ASSERT_EXIT(write(fd, buf, ct), testing::KilledBySignal(SIGABRT), "");
|
||||
close(fd);
|
||||
}
|
||||
|
||||
TEST_F(DEATHTEST, fread_fortified) {
|
||||
char buf[1];
|
||||
size_t ct = atoi("2"); // prevent optimizations
|
||||
|
||||
Reference in New Issue
Block a user