Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
System Manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
Issue 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
system
System Manager
Commits
40bb7f15
Commit
40bb7f15
authored
7 months ago
by
Amin Ben Romdhane
Browse files
Options
Downloads
Patches
Plain Diff
Improvment
parent
4250cc04
No related branches found
No related tags found
1 merge request
!11
Refresh dump output only when the new output is ready
Pipeline
#185115
passed
7 months ago
Stage: static_code_analysis
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/fwbank.c
+23
-8
23 additions, 8 deletions
src/fwbank.c
with
23 additions
and
8 deletions
src/fwbank.c
+
23
−
8
View file @
40bb7f15
...
...
@@ -283,27 +283,42 @@ static void fwbank_dump_finish_callback(struct ubus_context *ctx, struct ubus_re
close
(
pipe_fds
[
0
]);
// Close read end
if
(
bytes_read
<
0
)
{
if
(
bytes_read
<
0
||
strlen
(
buffer
)
==
0
)
{
BBF_ERR
(
"Failed to read from pipe"
);
goto
retry
;
}
free_global_fwbank_dump
(
&
g_fwbank_dump
.
output
);
// Use a temporary blob_buf for validation
struct
blob_buf
temp_buf
=
{
0
};
memset
(
&
g_fwbank_dump
.
output
,
0
,
sizeof
(
struct
blob_buf
));
blob_buf_init
(
&
g_fwbank_dump
.
output
,
0
);
memset
(
&
temp_buf
,
0
,
sizeof
(
struct
blob_buf
));
blob_buf_init
(
&
temp_buf
,
0
);
if
(
!
blobmsg_add_json_from_string
(
&
g_fwbank_dump
.
output
,
buffer
))
{
BBF_ERR
(
"Failed to create blob buf"
);
goto
retry
;
if
(
!
blobmsg_add_json_from_string
(
&
temp_buf
,
buffer
))
{
BBF_ERR
(
"Invalid JSON format in buffer"
);
blob_buf_free
(
&
temp_buf
);
goto
retry
;
}
int
res
=
validate_global_fwbank_dump
(
&
g_fwbank_dump
.
output
);
int
res
=
validate_global_fwbank_dump
(
&
temp_buf
);
if
(
res
)
{
BBF_ERR
(
"Failed to validate 'fwbank' output"
);
blob_buf_free
(
&
temp_buf
);
goto
retry
;
}
free_global_fwbank_dump
(
&
g_fwbank_dump
.
output
);
// Init g_fwbank_dump.output
memset
(
&
g_fwbank_dump
.
output
,
0
,
sizeof
(
struct
blob_buf
));
blob_buf_init
(
&
g_fwbank_dump
.
output
,
0
);
// Move validated JSON from temp_buf to g_fwbank_dump.output
blobmsg_add_blob
(
&
g_fwbank_dump
.
output
,
blob_data
(
temp_buf
.
head
));
// Free the temporary buffer
blob_buf_free
(
&
temp_buf
);
return
;
retry:
...
...
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