From 4187ed3907ad08cbb34c20cbf79d1bca6beb40b2 Mon Sep 17 00:00:00 2001 From: lubo-svk <49922839+lubo-svk@users.noreply.github.com> Date: Fri, 27 Sep 2024 13:01:39 +0200 Subject: [PATCH] The default value of doxm.sct set by iotivity-lite can be larger than 255 (#499) * The default value of doxm.sct set by iotivity-lite can be larger than uint8 which leads to a failed decoding of Doxm resource. --- pkg/codec/ocf/codec.go | 2 +- schema/credential/credential.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/codec/ocf/codec.go b/pkg/codec/ocf/codec.go index dc448afd..4e4d67ef 100644 --- a/pkg/codec/ocf/codec.go +++ b/pkg/codec/ocf/codec.go @@ -64,7 +64,7 @@ func (VNDOCFCBORCodec) Decode(m *pool.Message, v interface{}) error { } if err := cbor.ReadFrom(m.Body(), v); err != nil { p, _ := m.Options().Path() - return fmt.Errorf("decoding failed for the message %v on %v", m.Token(), p) + return fmt.Errorf("decoding failed for the message %v on %v with error: %w", m.Token(), p, err) } return nil } diff --git a/schema/credential/credential.go b/schema/credential/credential.go index ed029d9b..4a42a1cb 100644 --- a/schema/credential/credential.go +++ b/schema/credential/credential.go @@ -44,7 +44,7 @@ type Credential struct { Tag string `json:"tag,omitempty" yaml:"tag,omitempty"` } -type CredentialType uint8 +type CredentialType uint16 const ( CredentialType_EMPTY CredentialType = 0 @@ -86,7 +86,7 @@ func (c CredentialType) String() string { c &^= CredentialType_ASYMMETRIC_ENCRYPTION_KEY } if c != 0 { - res = append(res, fmt.Sprintf("unknown(%v)", uint8(c))) + res = append(res, fmt.Sprintf("unknown(%v)", uint16(c))) } return strings.Join(res, "|") }