dvidelabs / flatcc

FlatBuffers Compiler and Library in C for C
Apache License 2.0
632 stars 180 forks source link

Bad binary format may cause segmentation fault when call function verify #221

Closed Geneo-5 closed 2 years ago

Geneo-5 commented 2 years ago

Hi,

In binary format, a bad length string can cause segmentation fault. With sample monster, change "Orc" string lenght from 0003 0000 to FFFF FFFF, the call of verify crash.

00000000  04 00 00 00 84 ff ff ff  00 00 80 3f 00 00 00 40  |...........?...@|
00000010  00 00 40 40 30 00 00 00  1c 00 00 00 0c 00 00 00  |..@@0...........|
00000020  2c 00 00 00 2c 01 00 01  02 00 00 00 2c 00 00 00  |,...,.......,...|
00000030  1c 00 00 00 0a 00 00 00  00 01 02 03 04 05 06 07  |................|
00000040  08 09 00 00 ff ff ff ff  4f 72 63 00 d4 ff ff ff  |........Orc.....|
00000050  14 00 00 00 05 00 00 00  e0 ff ff ff 10 00 00 00  |................|
00000060  03 00 00 00 03 00 00 00  41 78 65 00 05 00 00 00  |........Axe.....|
00000070  53 77 6f 72 64 00 00 00  08 00 0a 00 04 00 08 00  |Sword...........|
00000080  18 00 24 00 04 00 00 00  20 00 10 00 00 00 14 00  |..$..... .......|
00000090  22 00 18 00 23 00 1c 00                           |"...#...|