Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iotivity-lite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
31
Issues
31
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
IoTivity
iotivity-lite
Commits
ebfa39ba
Commit
ebfa39ba
authored
Jan 11, 2021
by
Jozef Kralik
Committed by
Kishen Maloor
Jan 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cloud: set expires_in to UINT16_MAX when is greater than UINT16_MAX
parent
13a474b3
Pipeline
#1262
passed with stage
in 4 minutes and 56 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
11 deletions
+26
-11
api/cloud/oc_cloud_manager.c
api/cloud/oc_cloud_manager.c
+26
-11
No files found.
api/cloud/oc_cloud_manager.c
View file @
ebfa39ba
...
...
@@ -129,6 +129,25 @@ cloud_start_process(oc_cloud_context_t *ctx)
_oc_signal_event_loop
();
}
static
uint16_t
check_expires_in
(
int64_t
expires_in
)
{
if
(
expires_in
<=
0
)
{
return
0
;
}
if
(
expires_in
>
60
*
60
)
{
// if time is more than 1h then set expires to (expires_in - 10min).
expires_in
=
expires_in
-
10
*
60
;
}
else
if
(
expires_in
>
4
*
60
)
{
// if time is more than 240sec then set expires to (expires_in - 2min).
expires_in
=
expires_in
-
2
*
60
;
}
else
if
(
expires_in
>
20
)
{
// if time is more than 20sec then set expires to (expires_in - 10sec).
expires_in
=
expires_in
-
10
;
}
return
expires_in
>
UINT16_MAX
?
UINT16_MAX
:
(
uint16_t
)
expires_in
;
}
static
int
_register_handler
(
oc_cloud_context_t
*
ctx
,
oc_client_response_t
*
data
)
{
...
...
@@ -180,12 +199,10 @@ _register_handler(oc_cloud_context_t *ctx, oc_client_response_t *data)
}
int64_t
expires_in
=
0
;
if
(
oc_rep_get_int
(
payload
,
EXPIRESIN_KEY
,
&
expires_in
)
&&
expires_in
>
0
&&
expires_in
<=
UINT16_MAX
)
{
oc_rep_get_int
(
payload
,
EXPIRESIN_KEY
,
&
expires_in
);
ctx
->
expires_in
=
check_expires_in
(
expires_in
);
if
(
ctx
->
expires_in
>
0
)
{
ctx
->
store
.
status
|=
OC_CLOUD_TOKEN_EXPIRY
;
ctx
->
expires_in
=
(
uint16_t
)
expires_in
;
}
else
{
ctx
->
expires_in
=
0
;
}
cloud_store_dump_async
(
&
ctx
->
store
);
...
...
@@ -410,13 +427,11 @@ _refresh_token_handler(oc_cloud_context_t *ctx, oc_client_response_t *data)
goto
error
;
}
ctx
->
expires_in
=
0
;
if
(
oc_rep_get_int
(
payload
,
EXPIRESIN_KEY
,
&
expires_in
))
{
if
(
expires_in
>
0
&&
expires_in
<=
UINT16_MAX
)
{
ctx
->
expires_in
=
(
uint16_t
)
expires_in
;
oc_rep_get_int
(
payload
,
EXPIRESIN_KEY
,
&
expires_in
);
ctx
->
expires_in
=
check_expires_in
(
expires_in
);
if
(
ctx
->
expires_in
>
0
)
{
ctx
->
store
.
status
|=
OC_CLOUD_TOKEN_EXPIRY
;
}
}
cloud_store_dump_async
(
&
ctx
->
store
);
...
...
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