projects
/
test-ssd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Don't write outside the requested range
[test-ssd.git]
/
test-ssd-write.c
diff --git
a/test-ssd-write.c
b/test-ssd-write.c
index 5b7c8c4df06f218338d2cd7f96272fbd565fbd09..ea852481e6b94f776cf8df1b983fac7293249311 100644
(file)
--- a/
test-ssd-write.c
+++ b/
test-ssd-write.c
@@
-146,13
+146,18
@@
static int rand_write(int fd, size_t len)
uint64_t valcount;
int ret;
uint64_t valcount;
int ret;
+ if (len < BUFLEN) {
+ fprintf(stderr, "Error: File size needs to be at least %u\n", BUFLEN);
+ exit(EXIT_FAILURE);
+ }
+
memset(buf, 0, BUFLEN);
for (;;) {
if (len > UINT32_MAX) {
memset(buf, 0, BUFLEN);
for (;;) {
if (len > UINT32_MAX) {
- offset = (((size_t) rand() << 32) + (size_t) rand()) %
len
;
+ offset = (((size_t) rand() << 32) + (size_t) rand()) %
(len - BUFLEN)
;
} else {
} else {
- offset = rand() %
len
;
+ offset = rand() %
(len - BUFLEN)
;
}
if ((offset >= validate_offset &&
}
if ((offset >= validate_offset &&
This page took
0.022775 seconds
and
4
git commands to generate.