Commit 49a42cea authored by Kishen Maloor's avatar Kishen Maloor

oc_swupdate: fix logic in resource handler

Change-Id: I07ea6b3325bbb5fb861e5228b3d9f5873707718d
Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parent 032847fd
......@@ -401,6 +401,8 @@ oc_swupdate_decode(oc_rep_t *rep, size_t device)
memcmp(oc_string(rep->name), "nv", 2) == 0) {
if (oc_string_len(s->nv) > 0) {
oc_free_string(&s->nv);
}
if (oc_string_len(rep->value.string) > 0) {
oc_new_string(&s->nv, oc_string(rep->value.string),
oc_string_len(rep->value.string));
}
......@@ -409,6 +411,8 @@ oc_swupdate_decode(oc_rep_t *rep, size_t device)
memcmp(oc_string(rep->name), "purl", 4) == 0) {
if (oc_string_len(s->purl) > 0) {
oc_free_string(&s->purl);
}
if (oc_string_len(rep->value.string) > 0) {
oc_new_string(&s->purl, oc_string(rep->value.string),
oc_string_len(rep->value.string));
}
......@@ -417,6 +421,8 @@ oc_swupdate_decode(oc_rep_t *rep, size_t device)
memcmp(oc_string(rep->name), "signed", 6) == 0) {
if (oc_string_len(s->signage) > 0) {
oc_free_string(&s->signage);
}
if (oc_string_len(rep->value.string) > 0) {
oc_new_string(&s->signage, oc_string(rep->value.string),
oc_string_len(rep->value.string));
}
......@@ -485,11 +491,13 @@ post_sw(oc_request_t *request, oc_interface_mask_t interfaces, void *user_data)
if (oc_string_len(rep->name) == 2 &&
memcmp(oc_string(rep->name), "nv", 2) == 0) {
/* Read-only property */
error_state = true;
}
if (oc_string_len(rep->name) == 4 &&
memcmp(oc_string(rep->name), "purl", 4) == 0) {
if (rep->type != OC_REP_STRING) {
error_state = true;
}
if (oc_string_len(rep->value.string) >= 63) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment