cloudwu / pbc

A protocol buffers library for C
MIT License
1.62k stars 568 forks source link

SEGV issue detected in pbc_wmessage_string src/wmessage.c:281:8 #160

Open HotSpurzzZ opened 1 year ago

HotSpurzzZ commented 1 year ago

A SEGV has occurred when running program addressbook.

POC file:

https://github.com/HotSpurzzZ/testcases/blob/main/pbc/pbc_SEGV_pbc_wmessage_string

Verification steps :

1.Get the source code of pbc 2.Compile (Note the modification of the makefile to use AddressSanitizer) cd pbc make 3.use poc and run test mv $poc addressbook.pb ./addressbook

AddressSanitizer output :


$ ./addressbook
AddressSanitizer:DEADLYSIGNAL
=================================================================
==27761==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000042f8d5 bp 0x7ffd45cea810 sp 0x7ffd45ce9fb0 T0)
==27761==The signal is caused by a READ memory access.
==27761==Hint: address points to the zero page.
    #0 0x42f8d5 in strncmp (/root/Desktop/pbc/build/addressbook+0x42f8d5)
    #1 0x4d138f in pbc_wmessage_string /root/Desktop/pbc/src/wmessage.c:281:8
    #2 0x4c629c in test_wmessage /root/Desktop/pbc/build/../test/addressbook.c:78:2
    #3 0x4c629c in main /root/Desktop/pbc/build/../test/addressbook.c:105:29
    #4 0x7f9aec277082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
    #5 0x41c31d in _start (/root/Desktop/pbc/build/addressbook+0x41c31d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/root/Desktop/pbc/build/addressbook+0x42f8d5) in strncmp
==27761==ABORTING