@@ -69,32 +69,27 @@ Decoder::Status CBORMessageDecoder::decode(Message * message, uint8_t const * co
69
69
******************************************************************************/
70
70
71
71
bool copyCBORStringToArray (CborValue * param, char * dest, size_t dest_size) {
72
- if (!cbor_value_is_text_string (param)) {
73
- return false ;
74
- }
75
-
76
- // NOTE: keep in mind that _cbor_value_copy_string tries to put a \0 at the end of the string
77
- if (_cbor_value_copy_string (param, dest, &dest_size, NULL ) != CborNoError) {
78
- return false ;
72
+ if (cbor_value_is_text_string (param)) {
73
+ // NOTE: keep in mind that _cbor_value_copy_string tries to put a \0 at the end of the string
74
+ if (_cbor_value_copy_string (param, dest, &dest_size, NULL ) == CborNoError) {
75
+ return true ;
76
+ }
79
77
}
80
78
81
- return true ;
79
+ return false ;
82
80
}
83
81
84
82
// FIXME dest_size should be also returned, the copied byte array can have a different size from the starting one
85
83
// for the time being we need this on SHA256 only
86
84
bool copyCBORByteToArray (CborValue * param, uint8_t * dest, size_t dest_size) {
87
- if (!cbor_value_is_byte_string (param)) {
88
- return false ;
89
- }
90
-
91
- // NOTE: keep in mind that _cbor_value_copy_string tries to put a \0 at the end of the string
92
- if (_cbor_value_copy_string (param, dest, &dest_size, NULL ) != CborNoError) {
93
-
94
- return false ;
85
+ if (cbor_value_is_byte_string (param)) {
86
+ // NOTE: keep in mind that _cbor_value_copy_string tries to put a \0 at the end of the string
87
+ if (_cbor_value_copy_string (param, dest, &dest_size, NULL ) == CborNoError) {
88
+ return true ;
89
+ }
95
90
}
96
91
97
- return true ;
92
+ return false ;
98
93
}
99
94
100
95
CBORMessageDecoder::ArrayParserState CBORMessageDecoder::handle_EnterArray (CborValue * main_iter, CborValue * array_iter) {
0 commit comments