Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
23121ce7
Commit
23121ce7
authored
Aug 01, 2024
by
Jonas Kaufmann
Committed by
Antoine Kaufmann
Aug 18, 2024
Browse files
lib/simbricks/axi_subordiante: fix buffer overflow for unaligned reads/writes
parent
7dfdc0a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
lib/simbricks/axi/axi_subordinate.hh
lib/simbricks/axi/axi_subordinate.hh
+4
-2
No files found.
lib/simbricks/axi/axi_subordinate.hh
View file @
23121ce7
...
...
@@ -351,7 +351,8 @@ template <size_t BytesAddr, size_t BytesId, size_t BytesData,
void
AXISubordinateRead
<
BytesAddr
,
BytesId
,
BytesData
,
MaxInFlight
>::
send_next_data_segment
()
{
size_t
align
=
(
cur_op_
->
addr
+
cur_off_
)
%
BytesData
;
size_t
num_bytes
=
std
::
min
(
BytesData
-
align
,
cur_op_
->
step_size
);
size_t
num_bytes
=
std
::
min
(
{
BytesData
-
align
,
cur_op_
->
step_size
,
cur_op_
->
len
-
cur_off_
});
std
::
memset
(
r_data_tmp_
,
0
,
BytesData
);
std
::
memcpy
(
r_data_tmp_
+
align
,
cur_op_
->
buf
.
get
()
+
cur_off_
,
num_bytes
);
...
...
@@ -409,7 +410,8 @@ void AXISubordinateWrite<BytesAddr, BytesId, BytesData, MaxInFlight>::step(
<<
" cur_off="
<<
cur_off_
<<
" step_size="
<<
cur_op_
->
step_size
<<
" align="
<<
align
<<
"
\n
"
;
#endif
size_t
num_bytes
=
std
::
min
(
BytesData
-
align
,
cur_op_
->
step_size
);
size_t
num_bytes
=
std
::
min
(
{
BytesData
-
align
,
cur_op_
->
step_size
,
cur_op_
->
len
-
cur_off_
});
std
::
memcpy
(
cur_op_
->
buf
.
get
()
+
cur_off_
,
w_data_
+
align
,
num_bytes
);
cur_off_
+=
num_bytes
;
assert
(
cur_off_
<=
cur_op_
->
len
&&
"AXI W cur_off_ > cur_op_->len"
);
...
...
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