Closed walzsi closed 4 months ago
While encoding works, a ZCBOR_ERR_INVALID_VALUE_ENCODING is logged during decoding when trying to decode a float value of 0.00.
Testing was done with zcbor 0.8.1 and Python 3.11.7
For example passing fb 00 00 00 00 00 00 00 00 to the decoder results in following log message:
fb 00 00 00 00 00 00 00 00
New backup (level 2) zcbor_uint32_expect zcbor_uint64_expect zcbor_uint64_decode zcbor_uint_decode rem: 11, cur: 0x5, ec: 0x3, err: 11, value_extract zcbor_multi_decode decode_sensor_value zcbor_uint32_decode zcbor_uint_decode rem: 10, cur: 0x0, ec: 0x2, err: 11, value_extract zcbor_float_decode zcbor_float16_decode zcbor_float16_bytes_decode ZCBOR_ERR_IF(ZCBOR_ADDITIONAL(state->payload) != additional_val, 6) ZCBOR_ERR(6) ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 6, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1147 ZCBOR_FAIL_IF(!float_check(state, ZCBOR_VALUE_IS_2_BYTES)) ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 6, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1155 ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 6, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1193 zcbor_float32_decode ZCBOR_ERR_IF(ZCBOR_ADDITIONAL(state->payload) != additional_val, 6) ZCBOR_ERR(6) ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 6, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1147 ZCBOR_FAIL_IF(!float_check(state, ZCBOR_VALUE_IS_4_BYTES)) ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 6, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1226 zcbor_float64_decode rem: 9, cur: 0xfb, ec: 0x1, err: 6, value_extract ZCBOR_ERR_IF((zcbor_header_len_ptr(result, result_len) != (len + 1)), 21) ZCBOR_ERR(21) ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 21, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:152 ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 21, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1297 ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 21, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1371 rem: 9, cur: 0xfb, ec: 0x1, err: 21, WEST_TOPDIR/twister-out/native_posix/lib.semi_handling/modules/senscom/lib/senscom_message/generated/src/senscom_reply_decode.c:284 decode_sensor_value error: ZCBOR_ERR_INVALID_VALUE_ENCODING
https://github.com/NordicSemiconductor/zcbor/pull/396 seems to fix it
While encoding works, a ZCBOR_ERR_INVALID_VALUE_ENCODING is logged during decoding when trying to decode a float value of 0.00.
Testing was done with zcbor 0.8.1 and Python 3.11.7
For example passing
fb 00 00 00 00 00 00 00 00
to the decoder results in following log message:New backup (level 2) zcbor_uint32_expect zcbor_uint64_expect zcbor_uint64_decode zcbor_uint_decode rem: 11, cur: 0x5, ec: 0x3, err: 11, value_extract zcbor_multi_decode decode_sensor_value zcbor_uint32_decode zcbor_uint_decode rem: 10, cur: 0x0, ec: 0x2, err: 11, value_extract zcbor_float_decode zcbor_float16_decode zcbor_float16_bytes_decode ZCBOR_ERR_IF(ZCBOR_ADDITIONAL(state->payload) != additional_val, 6) ZCBOR_ERR(6) ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 6, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1147 ZCBOR_FAIL_IF(!float_check(state, ZCBOR_VALUE_IS_2_BYTES)) ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 6, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1155 ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 6, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1193 zcbor_float32_decode ZCBOR_ERR_IF(ZCBOR_ADDITIONAL(state->payload) != additional_val, 6) ZCBOR_ERR(6) ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 6, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1147 ZCBOR_FAIL_IF(!float_check(state, ZCBOR_VALUE_IS_4_BYTES)) ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 6, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1226 zcbor_float64_decode rem: 9, cur: 0xfb, ec: 0x1, err: 6, value_extract ZCBOR_ERR_IF((zcbor_header_len_ptr(result, result_len) != (len + 1)), 21) ZCBOR_ERR(21) ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 21, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:152 ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 21, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1297 ZCBOR_FAIL rem: 9, cur: 0xfb, ec: 0x1, err: 21, WEST_TOPDIR/modules/lib/zcbor/src/zcbor_decode.c:1371 rem: 9, cur: 0xfb, ec: 0x1, err: 21, WEST_TOPDIR/twister-out/native_posix/lib.semi_handling/modules/senscom/lib/senscom_message/generated/src/senscom_reply_decode.c:284 decode_sensor_value error: ZCBOR_ERR_INVALID_VALUE_ENCODING