tinycbor icon indicating copy to clipboard operation
tinycbor copied to clipboard

CBOR validation not works

Open rickou opened this issue 1 year ago • 0 comments

hi,

i try to validate my CBOR stream using cbor_value_validate_basic.

i always get error with the first signature tag (even if the stream is ok) D9D9F7A300A300196BCF010002C11A3843138001A100F502A100A300F401F93C0002F94D00

the decoded form is:

d9 d9f7                 # self describe cbor, tag(55799)
   a3                   #   map(3)
      00                #     unsigned(0)
      a3                #     map(3)
         00             #       unsigned(0)
         19 6bcf        #       unsigned(27,599)
         01             #       unsigned(1)
         00             #       unsigned(0)
         02             #       unsigned(2)
         c1             #       epoch datetime value, tag(1)
            1a 38431380 #         unsigned(943,920,000)
                        #         datetime(1999-11-30T00:00:00Z)
      01                #     unsigned(1)
      a1                #     map(1)
         00             #       unsigned(0)
         f5             #       true, simple(21)
      02                #     unsigned(2)
      a1                #     map(1)
         00             #       unsigned(0)
         a3             #       map(3)
            00          #         unsigned(0)
            f4          #         false, simple(20)
            01          #         unsigned(1)
            f9 3c00     #         float(1)
            02          #         unsigned(2)
            f9 4d00     #         float(20)

if i skip the signature tag before calling cbor_value_validate_basic and introduce a bad map definition (2 declared and 3 items) D9D9F7A300**A2**00196BCF010002C11A3843138001A100F502A100A300F401F93C0002F94D00 The function returns no error.

using https://cbor.nemo157.com/, the stream problem is identified. Error: TODO cbor-diag::Error: Remaining bytes (02a100a300f401f93c0002f94d00)

I have not identified in the lib where can be the problem except after returning, the remaining field is not 0.

rickou avatar Oct 22 '24 18:10 rickou