@@ -420,6 +420,33 @@ CborError cbor_parser_init(const uint8_t *buffer, size_t size, int flags, CborPa
420
420
* \sa cbor_value_advance(), cbor_valie_at_end(), cbor_value_get_type()
421
421
*/
422
422
423
+ /**
424
+ * Performs a basic validation of the CBOR stream pointed by \a it and returns
425
+ * the error it found. If no error was found, it returns CborNoError and the
426
+ * application can iterate over the items with certainty that no other errors
427
+ * will appear during parsing.
428
+ *
429
+ * A basic validation checks for:
430
+ * \list
431
+ * \li absence of undefined additional information bytes;
432
+ * \li well-formedness of all numbers, lengths, and simple values;
433
+ * \li string contents match reported sizes;
434
+ * \li arrays and maps contain the number of elements they are reported to have;
435
+ * \endlist
436
+ *
437
+ * For further checks, see cbor_value_validate().
438
+ *
439
+ * This function has the same timing and memory requirements as
440
+ * cbor_value_advance().
441
+ *
442
+ * \sa cbor_value_validate(), cbor_value_advance()
443
+ */
444
+ CborError cbor_value_validate_basic (const CborValue * it )
445
+ {
446
+ CborValue value = * it ;
447
+ return cbor_value_advance (& value );
448
+ }
449
+
423
450
/**
424
451
* Advances the CBOR value \a it by one fixed-size position. Fixed-size types
425
452
* are: integers, tags, simple types (including boolean, null and undefined
@@ -481,6 +508,9 @@ static CborError advance_recursive(CborValue *it, int nestingLevel)
481
508
* elements or chunks and will use O(n) memory for the number of nested
482
509
* containers).
483
510
*
511
+ * The number of recursions can be limited at compile time to avoid stack
512
+ * exhaustion in constrained systems.
513
+ *
484
514
* \sa cbor_value_at_end(), cbor_value_advance_fixed(), cbor_value_enter_container(), cbor_value_leave_container()
485
515
*/
486
516
CborError cbor_value_advance (CborValue * it )
0 commit comments