Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault in cbor_typeof #15

Closed
moraxy opened this issue Jul 15, 2016 · 1 comment
Closed

Segfault in cbor_typeof #15

moraxy opened this issue Jul 15, 2016 · 1 comment

Comments

@moraxy
Copy link

moraxy commented Jul 15, 2016

The file findings_000000 (hex dump below) causes the readline example to crash with a segfault due to a NULL pointer in common.c cbor_typeof carried over from main.c

00000000  e3 64 68 61 6c 66 f9 00  00 66 73 69 6e 67 6c 65  |.dhalf...fsingle|
00000010  fa 7f 7f ff ff 6d 73 69  6d 70 6c 65 20 76 61 6c  |.....msimple val|
00000020  75 65 73 83 f5 f4 f6                              |ues....|
00000027
backtrace
#0  0x000000000040670b in cbor_typeof (item=0x0) at libcbor/src/cbor/common.c:61
#1  0x000000000040370d in _cbor_nested_describe (item=0x0, out=0x7ffff7dd4400 <_IO_2_1_stdout_>, indent=0x0) at libcbor/src/cbor.c:260
#2  0x0000000000403e06 in cbor_describe (item=0x0, out=0x7ffff7dd4400 <_IO_2_1_stdout_>) at libcbor/src/cbor.c:388
#3  0x0000000000402fca in main (argc=0x2, argv=0x7fffffffe5c8) at libcbor/examples/readfile.c:39
#4  0x00007ffff7a36f45 in __libc_start_main (main=0x402ee5 <main>, argc=0x2, argv=0x7fffffffe5c8, init=<optimized out>, fini=<optimized out>,
    rtld_fini=<optimized out>, stack_end=0x7fffffffe5b8) at libc-start.c:287
#5  0x0000000000402e09 in _start ()
@PJK
Copy link
Owner

PJK commented Nov 6, 2016

Turns out that the example just doesn't correctly handle error conditions from the decoder (shame on me). Thanks for reporting!

@PJK PJK closed this as completed in 1eda0a7 Nov 6, 2016
PJK added a commit that referenced this issue Nov 6, 2016
Handle incorrect inputs in the example (fixes #15)
PJK added a commit that referenced this issue Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants