[Ocfs2-test-devel] [PATCH 42/59] mmap-test: fix segment fault
Junxiao Bi
junxiao.bi at oracle.com
Sun Sep 13 19:44:28 PDT 2015
When test file size is multiple of page size, there will be write out of
mmap range and cause segment fault.
Signed-off-by: Junxiao Bi <junxiao.bi at oracle.com>
---
programs/mmap_test/mmap_test.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/programs/mmap_test/mmap_test.c b/programs/mmap_test/mmap_test.c
index 9edbb58..711bb81 100644
--- a/programs/mmap_test/mmap_test.c
+++ b/programs/mmap_test/mmap_test.c
@@ -80,6 +80,14 @@ int main(int argc, char *argv[])
}
offset = stat_buf.st_size % page_size;
+
+ /* fix offset if the file size is multiple of page size */
+ if (offset == 0)
+ offset = page_size;
+
+ if (offset > stat_buf.st_size)
+ offset = stat_buf.st_size;
+
ptr = buf + (stat_buf.st_size - offset);
remain = page_size - offset;
--
1.7.9.5
More information about the Ocfs2-test-devel
mailing list