Page MenuHomeFreeBSD

D38718.diff
No OneTemporary

D38718.diff

diff --git a/tests/sys/fs/fusefs/bmap.cc b/tests/sys/fs/fusefs/bmap.cc
--- a/tests/sys/fs/fusefs/bmap.cc
+++ b/tests/sys/fs/fusefs/bmap.cc
@@ -210,6 +210,8 @@
_)
).WillOnce(Invoke(ReturnImmediate([=](auto in, auto& out) {
size_t osize = in.body.read.size;
+
+ assert(osize < sizeof(out.body.bytes));
out.header.len = sizeof(struct fuse_out_header) + osize;
bzero(out.body.bytes, osize);
})));
diff --git a/tests/sys/fs/fusefs/fallocate.cc b/tests/sys/fs/fusefs/fallocate.cc
--- a/tests/sys/fs/fusefs/fallocate.cc
+++ b/tests/sys/fs/fusefs/fallocate.cc
@@ -70,6 +70,7 @@
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnImmediate([=](auto in, auto& out) {
+ assert(in.body.read.size <= sizeof(out.body.bytes));
out.header.len = sizeof(struct fuse_out_header) +
in.body.read.size;
memset(out.body.bytes, 'X', in.body.read.size);
@@ -79,6 +80,8 @@
const char *buf = (const char*)in.body.bytes +
sizeof(struct fuse_write_in);
+ assert(length <= sizeof(in.body.bytes) -
+ sizeof(struct fuse_write_in));
return (in.header.opcode == FUSE_WRITE &&
in.header.nodeid == ino &&
in.body.write.offset == off &&
diff --git a/tests/sys/fs/fusefs/io.cc b/tests/sys/fs/fusefs/io.cc
--- a/tests/sys/fs/fusefs/io.cc
+++ b/tests/sys/fs/fusefs/io.cc
@@ -141,6 +141,8 @@
ssize_t isize = in.body.write.size;
off_t iofs = in.body.write.offset;
+ assert((size_t)isize <= sizeof(in.body.bytes) -
+ sizeof(struct fuse_write_in));
ASSERT_EQ(isize, pwrite(m_backing_fd, buf, isize, iofs))
<< strerror(errno);
SET_OUT_HEADER_LEN(out, write);
@@ -158,6 +160,7 @@
void *buf = out.body.bytes;
ssize_t osize;
+ assert((size_t)isize <= sizeof(out.body.bytes));
osize = pread(m_backing_fd, buf, isize, iofs);
ASSERT_LE(0, osize) << strerror(errno);
out.header.len = sizeof(struct fuse_out_header) + osize;
diff --git a/tests/sys/fs/fusefs/mockfs.hh b/tests/sys/fs/fusefs/mockfs.hh
--- a/tests/sys/fs/fusefs/mockfs.hh
+++ b/tests/sys/fs/fusefs/mockfs.hh
@@ -206,7 +206,7 @@
* The protocol places no limits on the size of bytes. Choose
* a size big enough for anything we'll test.
*/
- uint8_t bytes[0x20000];
+ uint8_t bytes[0x40000];
fuse_entry_out entry;
fuse_entry_out_7_8 entry_7_8;
fuse_lk_out getlk;
diff --git a/tests/sys/fs/fusefs/setattr.cc b/tests/sys/fs/fusefs/setattr.cc
--- a/tests/sys/fs/fusefs/setattr.cc
+++ b/tests/sys/fs/fusefs/setattr.cc
@@ -530,6 +530,7 @@
auto osize = std::min(
static_cast<uint64_t>(cur_size) - in.body.read.offset,
static_cast<uint64_t>(in.body.read.size));
+ assert(osize <= sizeof(out.body.bytes));
out.header.len = sizeof(struct fuse_out_header) + osize;
if (should_have_data)
memset(out.body.bytes, 'X', osize);
diff --git a/tests/sys/fs/fusefs/utils.cc b/tests/sys/fs/fusefs/utils.cc
--- a/tests/sys/fs/fusefs/utils.cc
+++ b/tests/sys/fs/fusefs/utils.cc
@@ -400,6 +400,7 @@
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
+ assert(osize <= sizeof(out.body.bytes));
out.header.len = sizeof(struct fuse_out_header) + osize;
memmove(out.body.bytes, contents, osize);
}))).RetiresOnSaturation();
@@ -502,6 +503,8 @@
bool pid_ok;
uint32_t wf = in.body.write.write_flags;
+ assert(isize <= sizeof(in.body.bytes) -
+ sizeof(struct fuse_write_in));
if (wf & FUSE_WRITE_CACHE)
pid_ok = true;
else
@@ -534,6 +537,9 @@
const char *buf = (const char*)in.body.bytes +
FUSE_COMPAT_WRITE_IN_SIZE;
bool pid_ok = (pid_t)in.header.pid == getpid();
+
+ assert(isize <= sizeof(in.body.bytes) -
+ FUSE_COMPAT_WRITE_IN_SIZE);
return (in.header.opcode == FUSE_WRITE &&
in.header.nodeid == ino &&
in.body.write.fh == FH &&
diff --git a/tests/sys/fs/fusefs/write.cc b/tests/sys/fs/fusefs/write.cc
--- a/tests/sys/fs/fusefs/write.cc
+++ b/tests/sys/fs/fusefs/write.cc
@@ -97,6 +97,8 @@
const char *buf = (const char*)in.body.bytes +
sizeof(struct fuse_write_in);
+ assert(size <= sizeof(in.body.bytes) -
+ sizeof(struct fuse_write_in));
return (in.header.opcode == FUSE_WRITE &&
in.header.nodeid == ino &&
in.body.write.offset == offset &&

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 11:22 AM (21 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14696642
Default Alt Text
D38718.diff (4 KB)

Event Timeline