Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cellframe-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
20
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
cellframe-sdk
Commits
d5bc00c2
Commit
d5bc00c2
authored
3 years ago
by
alexander.lysikov
Browse files
Options
Downloads
Patches
Plain Diff
fixed bug 5906
parent
75cd61be
No related branches found
No related tags found
2 merge requests
!640
Release 3.1
,
!568
Fixed bug 5906
Pipeline
#13236
passed with stage
in 4 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/global-db/dap_chain_global_db_remote.c
+55
-56
55 additions, 56 deletions
modules/global-db/dap_chain_global_db_remote.c
with
55 additions
and
56 deletions
modules/global-db/dap_chain_global_db_remote.c
+
55
−
56
View file @
d5bc00c2
...
@@ -295,65 +295,64 @@ unsigned char *pdata;
...
@@ -295,65 +295,64 @@ unsigned char *pdata;
* @param store_obj_count[out] a number of deserialized objects in the array
* @param store_obj_count[out] a number of deserialized objects in the array
* @return Returns a pointer to the first object in the array, if successful; otherwise NULL.
* @return Returns a pointer to the first object in the array, if successful; otherwise NULL.
*/
*/
dap_store_obj_t
*
dap_store_unpacket_multiple
(
const
dap_store_obj_pkt_t
*
pkt
,
size_t
*
store_obj_count
)
dap_store_obj_t
*
dap_store_unpacket_multiple
(
const
dap_store_obj_pkt_t
*
a_
pkt
,
size_t
*
a_
store_obj_count
)
{
{
if
(
!
pkt
||
pkt
->
data_size
<
1
)
if
(
!
a_
pkt
||
a_
pkt
->
data_size
<
1
)
return
NULL
;
return
NULL
;
uint64_t
offset
=
0
;
uint64_t
l_
offset
=
0
;
uint32_t
count
=
pkt
->
obj_count
;
uint32_t
l_
count
=
a_
pkt
->
obj_count
,
l_cur_count
;
dap_store_obj_t
*
store_obj
=
DAP_NEW_SIZE
(
dap_store_obj_t
,
count
*
sizeof
(
struct
dap_store_obj
));
dap_store_obj_t
*
l_
store_obj
=
DAP_NEW_
Z_
SIZE
(
dap_store_obj_t
,
l_
count
*
sizeof
(
struct
dap_store_obj
));
for
(
size_t
q
=
0
;
q
<
count
;
++
q
)
{
for
(
l_cur_count
=
0
;
l_cur_count
<
l_
count
;
++
l_cur_count
)
{
dap_store_obj_t
*
obj
=
store_obj
+
q
;
dap_store_obj_t
*
l_
obj
=
l_
store_obj
+
l_cur_count
;
uint16_t
str_length
;
uint16_t
l_
str_length
;
uint32_t
l_type
;
uint32_t
l_type
;
if
(
offset
+
sizeof
(
uint32_t
)
>
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'type' field"
);
break
;}
// Check for buffer boundries
if
(
l_
offset
+
sizeof
(
uint32_t
)
>
a_
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'type' field"
);
break
;}
// Check for buffer boundries
memcpy
(
&
l_type
,
pkt
->
data
+
offset
,
sizeof
(
uint32_t
));
memcpy
(
&
l_type
,
a_
pkt
->
data
+
l_
offset
,
sizeof
(
uint32_t
));
obj
->
type
=
l_type
;
l_
obj
->
type
=
l_type
;
offset
+=
sizeof
(
uint32_t
);
l_
offset
+=
sizeof
(
uint32_t
);
if
(
offset
+
sizeof
(
uint16_t
)
>
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'group_length' field"
);
break
;}
// Check for buffer boundries
if
(
l_
offset
+
sizeof
(
uint16_t
)
>
a_
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'group_length' field"
);
break
;}
// Check for buffer boundries
memcpy
(
&
str_length
,
pkt
->
data
+
offset
,
sizeof
(
uint16_t
));
memcpy
(
&
l_
str_length
,
a_
pkt
->
data
+
l_
offset
,
sizeof
(
uint16_t
));
offset
+=
sizeof
(
uint16_t
);
l_
offset
+=
sizeof
(
uint16_t
);
if
(
offset
+
str_length
>
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'group' field"
);
break
;}
// Check for buffer boundries
if
(
l_
offset
+
l_
str_length
>
a_
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'group' field"
);
break
;}
// Check for buffer boundries
obj
->
group
=
DAP_NEW_SIZE
(
char
,
str_length
+
1
);
l_
obj
->
group
=
DAP_NEW_SIZE
(
char
,
l_
str_length
+
1
);
memcpy
(
(
char
*
)
obj
->
group
,
pkt
->
data
+
offset
,
str_length
);
memcpy
(
l_
obj
->
group
,
a_
pkt
->
data
+
l_
offset
,
l_
str_length
);
((
char
*
)
obj
->
group
)
[
str_length
]
=
'\0'
;
l_
obj
->
group
[
l_
str_length
]
=
'\0'
;
offset
+=
str_length
;
l_
offset
+=
l_
str_length
;
if
(
offset
+
sizeof
(
uint64_t
)
>
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'id' field"
);
break
;}
// Check for buffer boundries
if
(
l_
offset
+
sizeof
(
uint64_t
)
>
a_
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'id' field"
);
break
;}
// Check for buffer boundries
memcpy
(
&
obj
->
id
,
pkt
->
data
+
offset
,
sizeof
(
uint64_t
));
memcpy
(
&
l_
obj
->
id
,
a_
pkt
->
data
+
l_
offset
,
sizeof
(
uint64_t
));
offset
+=
sizeof
(
uint64_t
);
l_
offset
+=
sizeof
(
uint64_t
);
if
(
offset
+
sizeof
(
uint64_t
)
>
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'timestamp' field"
);
break
;}
// Check for buffer boundries
if
(
l_
offset
+
sizeof
(
uint64_t
)
>
a_
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'timestamp' field"
);
break
;}
// Check for buffer boundries
memcpy
(
&
obj
->
timestamp
,
pkt
->
data
+
offset
,
sizeof
(
uint64_t
));
memcpy
(
&
l_
obj
->
timestamp
,
a_
pkt
->
data
+
l_
offset
,
sizeof
(
uint64_t
));
offset
+=
sizeof
(
uint64_t
);
l_
offset
+=
sizeof
(
uint64_t
);
if
(
offset
+
sizeof
(
uint16_t
)
>
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'key_length' field"
);
break
;}
// Check for buffer boundries
if
(
l_
offset
+
sizeof
(
uint16_t
)
>
a_
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'key_length' field"
);
break
;}
// Check for buffer boundries
memcpy
(
&
str_length
,
pkt
->
data
+
offset
,
sizeof
(
uint16_t
));
memcpy
(
&
l_
str_length
,
a_
pkt
->
data
+
l_
offset
,
sizeof
(
uint16_t
));
offset
+=
sizeof
(
uint16_t
);
l_
offset
+=
sizeof
(
uint16_t
);
if
(
offset
+
str_length
>
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'key' field"
);
break
;}
// Check for buffer boundries
if
(
l_
offset
+
l_
str_length
>
a_
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'key' field"
);
break
;}
// Check for buffer boundries
obj
->
key
=
DAP_NEW_SIZE
(
char
,
str_length
+
1
);
l_
obj
->
key
=
DAP_NEW_SIZE
(
char
,
l_
str_length
+
1
);
memcpy
(
(
char
*
)
obj
->
key
,
pkt
->
data
+
offset
,
str_length
);
memcpy
(
l_
obj
->
key
,
a_
pkt
->
data
+
l_
offset
,
l_
str_length
);
((
char
*
)
obj
->
key
)
[
str_length
]
=
'\0'
;
l_
obj
->
key
[
l_
str_length
]
=
'\0'
;
offset
+=
str_length
;
l_
offset
+=
l_
str_length
;
if
(
offset
+
sizeof
(
uint64_t
)
>
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'value_length' field"
);
break
;}
// Check for buffer boundries
if
(
l_
offset
+
sizeof
(
uint64_t
)
>
a_
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'value_length' field"
);
break
;}
// Check for buffer boundries
memcpy
(
&
obj
->
value_len
,
pkt
->
data
+
offset
,
sizeof
(
uint64_t
));
memcpy
(
&
l_
obj
->
value_len
,
a_
pkt
->
data
+
l_
offset
,
sizeof
(
uint64_t
));
offset
+=
sizeof
(
uint64_t
);
l_
offset
+=
sizeof
(
uint64_t
);
if
(
offset
+
obj
->
value_len
>
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'value' field"
);
break
;}
// Check for buffer boundries
if
(
l_
offset
+
l_
obj
->
value_len
>
a_
pkt
->
data_size
)
{
log_it
(
L_ERROR
,
"Broken GDB element: can't read 'value' field"
);
break
;}
// Check for buffer boundries
obj
->
value
=
DAP_NEW_SIZE
(
uint8_t
,
obj
->
value_len
);
l_
obj
->
value
=
DAP_NEW_SIZE
(
uint8_t
,
l_
obj
->
value_len
);
memcpy
(
(
char
*
)
obj
->
value
,
pkt
->
data
+
offset
,
obj
->
value_len
);
memcpy
(
l_
obj
->
value
,
a_
pkt
->
data
+
l_
offset
,
l_
obj
->
value_len
);
offset
+=
obj
->
value_len
;
l_
offset
+=
l_
obj
->
value_len
;
}
}
assert
(
a_pkt
->
data_size
==
l_offset
);
assert
(
pkt
->
data_size
==
offset
);
// Return the number of completely filled dap_store_obj_t structures
// because l_cur_count may be less than l_count due to too little memory
if
(
store_obj_count
)
if
(
a_store_obj_count
)
*
store_obj_count
=
count
;
*
a_store_obj_count
=
l_cur_count
;
return
l_store_obj
;
return
store_obj
;
}
}
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