Skip to content

Commit 6136b40

Browse files
committed
Create CHECK_CBOR_MULTI macro to return CborErrorTooManyItems error if the whole property cannot be appended to the CBOR buffer. Doing so the complete CBOR message will be discarded.
1 parent f0328c0 commit 6136b40

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/cbor/lib/tinycbor/cbor-lib.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,16 @@
2121
} while(0);
2222
#endif /* CHECK_CBOR */
2323

24+
#ifndef CHECK_CBOR_MULTI
25+
#define CHECK_CBOR_MULTI(expr) \
26+
do { \
27+
CborError error = CborNoError; \
28+
error = (expr); \
29+
if (CborErrorOutOfMemory == error) \
30+
return CborErrorTooManyItems; \
31+
if (CborNoError != error) \
32+
return error; \
33+
} while(0);
34+
#endif /* CHECK_CBOR_MULTI */
35+
2436
#endif

0 commit comments

Comments
 (0)