Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Log 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
Log Manager
Commits
ad2636c6
Commit
ad2636c6
authored
1 month ago
by
Suvendhu Hansa
Browse files
Options
Downloads
Patches
Plain Diff
Fix empty params in transfer complete event
parent
1561b71a
No related branches found
No related tags found
1 merge request
!16
Fix empty params in transfer complete event
Pipeline
#216182
failed
1 week ago
Stage: static_code_analysis
Changes
1
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bbf_plugin/deviceinfovendorlog.c
+20
-17
20 additions, 17 deletions
bbf_plugin/deviceinfovendorlog.c
with
20 additions
and
17 deletions
bbf_plugin/deviceinfovendorlog.c
+
20
−
17
View file @
ad2636c6
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#include
"common.h"
#include
"common.h"
static
void
send_transfer_complete_event
(
struct
ubus_context
*
ubus_ctx
,
const
char
*
command
,
const
char
*
obj_path
,
const
char
*
transfer_url
,
static
void
send_transfer_complete_event
(
struct
ubus_context
*
ubus_ctx
,
const
char
*
command
,
const
char
*
obj_path
,
const
char
*
transfer_url
,
char
*
fault_string
,
time_t
start_t
,
time_t
complete_t
,
const
char
*
commandKey
,
const
char
*
transfer_type
)
char
*
fault_string
,
time_t
start_t
,
time_t
complete_t
,
const
char
*
commandKey
,
const
char
*
transfer_type
,
const
char
*
reqstr
)
{
{
char
start_time
[
32
]
=
{
0
};
char
start_time
[
32
]
=
{
0
};
char
complete_time
[
32
]
=
{
0
};
char
complete_time
[
32
]
=
{
0
};
...
@@ -31,12 +31,8 @@ static void send_transfer_complete_event(struct ubus_context *ubus_ctx, const ch
...
@@ -31,12 +31,8 @@ static void send_transfer_complete_event(struct ubus_context *ubus_ctx, const ch
void
*
arr
=
blobmsg_open_array
(
&
bb
,
"input"
);
void
*
arr
=
blobmsg_open_array
(
&
bb
,
"input"
);
fill_blob_param
(
&
bb
,
"Command"
,
command
,
DMT_TYPE
[
DMT_STRING
],
0
);
fill_blob_param
(
&
bb
,
"Command"
,
command
,
DMT_TYPE
[
DMT_STRING
],
0
);
if
(
commandKey
)
fill_blob_param
(
&
bb
,
"CommandKey"
,
commandKey
?
commandKey
:
""
,
DMT_TYPE
[
DMT_STRING
],
0
);
fill_blob_param
(
&
bb
,
"CommandKey"
,
commandKey
,
DMT_TYPE
[
DMT_STRING
],
0
);
fill_blob_param
(
&
bb
,
"Requestor"
,
reqstr
?
reqstr
:
""
,
DMT_TYPE
[
DMT_STRING
],
0
);
else
fill_blob_param
(
&
bb
,
"CommandKey"
,
""
,
DMT_TYPE
[
DMT_STRING
],
0
);
fill_blob_param
(
&
bb
,
"Requestor"
,
""
,
DMT_TYPE
[
DMT_STRING
],
0
);
fill_blob_param
(
&
bb
,
"TransferType"
,
transfer_type
,
DMT_TYPE
[
DMT_STRING
],
0
);
fill_blob_param
(
&
bb
,
"TransferType"
,
transfer_type
,
DMT_TYPE
[
DMT_STRING
],
0
);
fill_blob_param
(
&
bb
,
"Affected"
,
obj_path
,
DMT_TYPE
[
DMT_STRING
],
0
);
fill_blob_param
(
&
bb
,
"Affected"
,
obj_path
,
DMT_TYPE
[
DMT_STRING
],
0
);
fill_blob_param
(
&
bb
,
"TransferURL"
,
transfer_url
,
DMT_TYPE
[
DMT_STRING
],
0
);
fill_blob_param
(
&
bb
,
"TransferURL"
,
transfer_url
,
DMT_TYPE
[
DMT_STRING
],
0
);
...
@@ -70,7 +66,7 @@ static bool get_response_code_status(const char *url, int response_code)
...
@@ -70,7 +66,7 @@ static bool get_response_code_status(const char *url, int response_code)
}
}
static
int
bbf_upload_log
(
struct
ubus_context
*
ubus_ctx
,
const
char
*
url
,
const
char
*
username
,
const
char
*
password
,
static
int
bbf_upload_log
(
struct
ubus_context
*
ubus_ctx
,
const
char
*
url
,
const
char
*
username
,
const
char
*
password
,
char
*
config_name
,
const
char
*
command
,
const
char
*
obj_path
,
int
type
)
char
*
config_name
,
const
char
*
command
,
const
char
*
obj_path
,
int
type
,
const
char
*
cmdkey
,
const
char
*
reqstr
)
{
{
int
res
=
0
;
int
res
=
0
;
char
fault_msg
[
128
]
=
{
0
};
char
fault_msg
[
128
]
=
{
0
};
...
@@ -86,10 +82,8 @@ static int bbf_upload_log(struct ubus_context *ubus_ctx, const char *url, const
...
@@ -86,10 +82,8 @@ static int bbf_upload_log(struct ubus_context *ubus_ctx, const char *url, const
res
=
-
1
;
res
=
-
1
;
}
}
if
(
type
==
BBFDM_USP
)
{
// Send the transfer complete event
// Send the transfer complete event
send_transfer_complete_event
(
ubus_ctx
,
command
,
obj_path
,
url
,
fault_msg
,
start_time
,
complete_time
,
cmdkey
,
"Upload"
,
reqstr
);
send_transfer_complete_event
(
ubus_ctx
,
command
,
obj_path
,
url
,
fault_msg
,
start_time
,
complete_time
,
NULL
,
"Upload"
);
}
return
res
;
return
res
;
}
}
...
@@ -306,17 +300,26 @@ static int archive_log_file(char *arch_file, char *file_path)
...
@@ -306,17 +300,26 @@ static int archive_log_file(char *arch_file, char *file_path)
static
int
operate_DeviceInfoVendorLogFile_Upload
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
*
value
,
int
action
)
static
int
operate_DeviceInfoVendorLogFile_Upload
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
*
value
,
int
action
)
{
{
char
upload_path
[
256
]
=
{
0
};
char
upload_path
[
256
]
=
{
0
};
char
upload_command
[
3
2
]
=
{
0
};
char
upload_command
[
2
70
]
=
{
0
};
char
log_tar_file
[
256
]
=
{
0
};
char
log_tar_file
[
256
]
=
{
0
};
char
*
vlf_file_path
=
NULL
;
char
*
vlf_file_path
=
NULL
;
char
*
cmdkey
=
NULL
,
*
reqstr
=
NULL
;
int
res
;
int
res
;
DM_STRNCPY
(
log_tar_file
,
"/tmp/vendor_log-XXXXXX.tar"
,
sizeof
(
log_tar_file
));
DM_STRNCPY
(
log_tar_file
,
"/tmp/vendor_log-XXXXXX.tar"
,
sizeof
(
log_tar_file
));
char
*
ret
=
DM_STRRCHR
(
refparam
,
'.'
);
if
(
!
ret
)
return
USP_FAULT_INVALID_ARGUMENT
;
if
((
ret
-
refparam
+
2
)
<
sizeof
(
upload_path
))
{
snprintf
(
upload_path
,
ret
-
refparam
+
2
,
"%s"
,
refparam
);
}
if
(
ctx
->
dm_type
==
BBFDM_USP
)
{
if
(
ctx
->
dm_type
==
BBFDM_USP
)
{
char
*
ret
=
DM_STRRCHR
(
refparam
,
'.'
);
DM_STRNCPY
(
upload_command
,
refparam
,
sizeof
(
upload_command
)
);
strncpy
(
upload_path
,
refparam
,
ret
-
refparam
+
1
);
cmdkey
=
dmjson_get_value
((
json_object
*
)
value
,
1
,
"__BBF_CommandKey"
);
DM_STRNCPY
(
upload_command
,
ret
+
1
,
sizeof
(
upload_command
)
);
reqstr
=
dmjson_get_value
((
json_object
*
)
value
,
1
,
"__BBF_Requestor"
);
}
}
char
*
user
=
dmjson_get_value
((
json_object
*
)
value
,
1
,
"Username"
);
char
*
user
=
dmjson_get_value
((
json_object
*
)
value
,
1
,
"Username"
);
...
@@ -343,7 +346,7 @@ static int operate_DeviceInfoVendorLogFile_Upload(char *refparam, struct dmctx *
...
@@ -343,7 +346,7 @@ static int operate_DeviceInfoVendorLogFile_Upload(char *refparam, struct dmctx *
}
}
if
(
res
==
0
)
{
if
(
res
==
0
)
{
res
=
bbf_upload_log
(
ctx
->
ubus_ctx
,
url
,
user
,
pass
,
log_tar_file
,
upload_command
,
upload_path
,
ctx
->
dm_type
);
res
=
bbf_upload_log
(
ctx
->
ubus_ctx
,
url
,
user
,
pass
,
log_tar_file
,
upload_command
,
upload_path
,
ctx
->
dm_type
,
cmdkey
,
reqstr
);
}
}
if
(
file_exists
(
log_tar_file
))
if
(
file_exists
(
log_tar_file
))
...
...
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