Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
eaa5832c
Commit
eaa5832c
authored
Feb 13, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
5126d2be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
wcfs/client/wcfs.cpp
wcfs/client/wcfs.cpp
+8
-4
No files found.
wcfs/client/wcfs.cpp
View file @
eaa5832c
...
...
@@ -385,7 +385,6 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
xerr
::
Contextf
E
(
"wcfs %s: conn @%s: mmap f<%s> [blk%ld +blk%ld)"
,
v
(
f
.
wconn
->
_wc
->
mountpoint
),
v
(
f
.
wconn
->
at
),
v
(
f
.
foid
),
blk_start
,
blk_len
);
// XXX (blk_start + blk_len) * blk_size overflow
error
err
;
if
(
blk_start
<
0
)
...
...
@@ -393,20 +392,25 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
if
(
blk_len
<
0
)
panic
(
"blk_len < 0"
);
int64_t
blk_stop
=
blk_start
+
blk_len
;
// XXX overflow
int64_t
blk_stop
;
// = blk_start + blk_len
if
(
__builtin_add_overflow
(
blk_start
,
blk_len
,
&
blk_stop
))
panic
(
"blk_start + blk_len overflow int64"
);
int64_t
stop
;
// = blk_stop *f.blksize;
if
(
__builtin_mul_overflow
(
blk_stop
,
f
.
blksize
,
&
stop
))
panic
(
"(blk_start + blk_len)*f.blksize overflow int64"
);
int64_t
start
=
blk_start
*
f
.
blksize
;
// XXX f locking?
// create memory with head/f mapping and applied pins
// mmap-in zeros after f.size (else access to memory after file.size will raise SIGBUS)
int64_t
start
=
blk_start
*
f
.
blksize
;
uint8_t
*
mem_start
,
*
mem_stop
;
tie
(
mem_start
,
err
)
=
mmap_ro
(
f
.
_headf
,
start
,
blk_len
*
f
.
blksize
);
if
(
err
!=
nil
)
return
make_pair
(
nil
,
E
(
err
));
mem_stop
=
mem_start
+
blk_len
*
f
.
blksize
;
int64_t
stop
=
blk_stop
*
f
.
blksize
;
if
(
stop
>
f
.
_headfsize
)
{
uint8_t
*
zmem_start
=
mem_start
+
(
max
(
f
.
_headfsize
/*XXX -1 ?*/
,
start
)
-
start
);
err
=
mmap_zero_into_ro
(
zmem_start
,
mem_stop
-
zmem_start
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment