Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cmp_tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dominik Loidolt
cmp_tool
Commits
61d7d404
Commit
61d7d404
authored
3 years ago
by
Dominik Loidolt
Browse files
Options
Downloads
Patches
Plain Diff
fix buffer overflow if data is set but data_size = 0
parent
df1ea83a
No related branches found
No related tags found
1 merge request
!6
Relax the requirements on the input format
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/rdcu_pkt_to_file.c
+6
-0
6 additions, 0 deletions
lib/rdcu_pkt_to_file.c
lib/rdcu_rmap.c
+11
-11
11 additions, 11 deletions
lib/rdcu_rmap.c
with
17 additions
and
11 deletions
lib/rdcu_pkt_to_file.c
+
6
−
0
View file @
61d7d404
...
...
@@ -144,6 +144,8 @@ static int32_t rmap_tx_to_file(const void *hdr, uint32_t hdr_size,
}
n
=
rdcu_package
(
NULL
,
hdr
,
hdr_size
,
non_crc_bytes
,
data
,
data_size
);
if
(
n
<=
0
)
return
-
1
;
blob
=
malloc
(
n
);
if
(
!
blob
)
{
printf
(
"malloc for tx_pkt faild
\n
"
);
...
...
@@ -151,6 +153,10 @@ static int32_t rmap_tx_to_file(const void *hdr, uint32_t hdr_size,
}
n
=
rdcu_package
(
blob
,
hdr
,
hdr_size
,
non_crc_bytes
,
data
,
data_size
);
if
(
n
<=
0
)
{
free
(
blob
);
return
-
1
;
}
fp
=
open_file
(
tc_folder_dir
,
n_pkt
);
...
...
This diff is collapsed.
Click to expand it.
lib/rdcu_rmap.c
+
11
−
11
View file @
61d7d404
...
...
@@ -595,7 +595,10 @@ int rdcu_package(uint8_t *blob,
if
(
data_size
&
0x3
)
/* must be multiple of 4 */
return
-
1
;
return
0
;
if
(
!
data_size
)
data
=
NULL
;
if
(
!
cmd_size
)
{
blob
=
NULL
;
...
...
@@ -609,7 +612,7 @@ int rdcu_package(uint8_t *blob,
ri
=
(
struct
rmap_instruction
*
)
&
cmd
[
non_crc_bytes
+
RMAP_INSTRUCTION
];
/* see if the type of command needs a data crc field at the end */
switch
(
ri
->
cmd
)
{
switch
(
ri
->
cmd
)
{
case
RMAP_READ_MODIFY_WRITE_ADDR_INC
:
case
RMAP_WRITE_ADDR_SINGLE
:
case
RMAP_WRITE_ADDR_INC
:
...
...
@@ -618,13 +621,12 @@ int rdcu_package(uint8_t *blob,
case
RMAP_WRITE_ADDR_SINGLE_VERIFY_REPLY
:
case
RMAP_WRITE_ADDR_INC_VERIFY_REPLY
:
case
RMAP_WRITE_ADDR_INC_REPLY
:
has_data_crc
=
1
;
n
+=
1
;
break
;
default:
break
;
}
has_data_crc
=
1
;
n
+=
1
;
break
;
default:
break
;
}
if
(
data
)
n
+=
data_size
;
...
...
@@ -632,7 +634,6 @@ int rdcu_package(uint8_t *blob,
if
(
!
blob
)
return
n
;
memcpy
(
&
blob
[
0
],
cmd
,
cmd_size
);
blob
[
cmd_size
]
=
rmap_crc8
(
&
cmd
[
non_crc_bytes
],
...
...
@@ -647,7 +648,6 @@ int rdcu_package(uint8_t *blob,
blob
[
cmd_size
+
1
]
=
0x0
;
}
return
n
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment