From 60138901935d4832599a1ead6486c152bc1a68d0 Mon Sep 17 00:00:00 2001 From: Kishen Maloor Date: Mon, 27 Apr 2020 17:41:14 -0400 Subject: [PATCH] oc_cloud:fix cloud_deregistered_internal() Signed-off-by: Kishen Maloor --- api/cloud/oc_cloud_apis.c | 3 ++- security/oc_cred.c | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/api/cloud/oc_cloud_apis.c b/api/cloud/oc_cloud_apis.c index 7700c9f64..34d44c354 100644 --- a/api/cloud/oc_cloud_apis.c +++ b/api/cloud/oc_cloud_apis.c @@ -231,7 +231,8 @@ cloud_deregistered_internal(oc_client_response_t *data) { cloud_api_param_t *p = (cloud_api_param_t *)data->user_data; oc_cloud_context_t *ctx = p->ctx; - if (data->code >= OC_STATUS_SERVICE_UNAVAILABLE) { + if (data->code < OC_STATUS_BAD_REQUEST || + data->code >= OC_STATUS_SERVICE_UNAVAILABLE) { ctx->store.status = OC_CLOUD_DEREGISTERED; } else if (data->code >= OC_STATUS_BAD_REQUEST) { cloud_set_last_error(ctx, CLOUD_ERROR_RESPONSE); diff --git a/security/oc_cred.c b/security/oc_cred.c index aee23e0dc..d68d46a9e 100644 --- a/security/oc_cred.c +++ b/security/oc_cred.c @@ -1086,12 +1086,14 @@ oc_sec_decode_cred(oc_rep_t *rep, oc_sec_cred_t **owner, bool from_storage, oc_sec_cred_t *cr = oc_sec_get_cred_by_credid(credid, device); if (cr) { cr->owner_cred = owner_cred; - } - /* Obtain a handle to the owner credential entry where that applies - */ - if (credtype == OC_CREDTYPE_PSK && privatedata_size == 0 && owner) { - *owner = cr; - (*owner)->owner_cred = true; + /* Obtain a handle to the owner credential entry where that + * applies + */ + if (credtype == OC_CREDTYPE_PSK && privatedata_size == 0 && + owner) { + *owner = cr; + (*owner)->owner_cred = true; + } } } creds_array = creds_array->next; -- GitLab