happyfish100 / libfastcommon

c common functions library extracted from my open source project FastDFS. this library is very simple and stable. functions including: string, logger, chain, hash, socket, ini file reader, base64 encode / decode, url encode / decode, fast timer, skiplist, object pool etc. detail info please see the c header files.
http://bbs.chinaunix.net/forum-240-1.html
GNU Lesser General Public License v3.0
898 stars 531 forks source link

Got a SIGABRT when calling fds_client_init with a nonexistent conf file #16

Open Madokakaroto opened 6 years ago

Madokakaroto commented 6 years ago

auto result = fdfs_client_init("/etc/fdf/client.conf"); I compiled it on ubuntu with gcc 6.2, and my program crashed. I guess there may be something wrong with your usage of calling sprintf.

The dump log is here: buffer overflow detected : ./test_fdfs terminated ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x7329f)[0x7f56e4a7e29f] /lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7f56e4b15bbc] /lib/x86_64-linux-gnu/libc.so.6(+0x109a90)[0x7f56e4b14a90] /lib/x86_64-linux-gnu/libc.so.6(+0x108f99)[0x7f56e4b13f99] /lib/x86_64-linux-gnu/libc.so.6(_IO_default_xsputn+0xbc)[0x7f56e4a8660c] /lib/x86_64-linux-gnu/libc.so.6(_IO_vfprintf+0xd0)[0x7f56e4a54d10] /lib/x86_64-linux-gnu/libc.so.6(vsprintf_chk+0x84)[0x7f56e4b14024] /lib/x86_64-linux-gnu/libc.so.6(sprintf_chk+0x7d)[0x7f56e4b13f7d] /usr/lib/libfastcommon.so(log_it_ex2+0x1a0)[0x7f56e45c9090] /usr/lib/libfastcommon.so(logError+0x130)[0x7f56e45ca830] /usr/lib/libfastcommon.so(getFileContent+0x214)[0x7f56e45bee64] /usr/lib/libfastcommon.so(+0x12112)[0x7f56e45c4112] /usr/lib/libfastcommon.so(iniLoadFromFileEx+0x4c2)[0x7f56e45c59c2] /usr/lib/libfdfsclient.so(fdfs_client_init_ex+0x31)[0x7f56e50ef69c] ./test_fdfs(main+0x32)[0x400b78] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f56e4a2cf45] ./test_fdfs[0x400a79] ======= Memory map: ======== 00400000-00401000 r-xp 00000000 08:02 6584315 /home/buke/programming/test/build/test_fdfs 00601000-00602000 r--p 00001000 08:02 6584315 /home/buke/programming/test/build/test_fdfs 00602000-00603000 rw-p 00002000 08:02 6584315 /home/buke/programming/test/build/test_fdfs 02135000-02167000 rw-p 00000000 00:00 0 [heap] 7f56e4095000-7f56e40ab000 r-xp 00000000 08:02 4195223 /lib/x86_64-linux-gnu/libgcc_s.so.1 7f56e40ab000-7f56e42aa000 ---p 00016000 08:02 4195223 /lib/x86_64-linux-gnu/libgcc_s.so.1 7f56e42aa000-7f56e42ab000 r--p 00015000 08:02 4195223 /lib/x86_64-linux-gnu/libgcc_s.so.1 7f56e42ab000-7f56e42ac000 rw-p 00016000 08:02 4195223 /lib/x86_64-linux-gnu/libgcc_s.so.1 7f56e42ac000-7f56e43b1000 r-xp 00000000 08:02 4194403 /lib/x86_64-linux-gnu/libm-2.19.so 7f56e43b1000-7f56e45b0000 ---p 00105000 08:02 4194403 /lib/x86_64-linux-gnu/libm-2.19.so 7f56e45b0000-7f56e45b1000 r--p 00104000 08:02 4194403 /lib/x86_64-linux-gnu/libm-2.19.so 7f56e45b1000-7f56e45b2000 rw-p 00105000 08:02 4194403 /lib/x86_64-linux-gnu/libm-2.19.so 7f56e45b2000-7f56e45eb000 r-xp 00000000 08:02 8150219 /usr/lib/libfastcommon.so 7f56e45eb000-7f56e47ea000 ---p 00039000 08:02 8150219 /usr/lib/libfastcommon.so 7f56e47ea000-7f56e47eb000 r--p 00038000 08:02 8150219 /usr/lib/libfastcommon.so 7f56e47eb000-7f56e47ec000 rw-p 00039000 08:02 8150219 /usr/lib/libfastcommon.so 7f56e47ec000-7f56e47ed000 rw-p 00000000 00:00 0 7f56e47ed000-7f56e4806000 r-xp 00000000 08:02 4195432 /lib/x86_64-linux-gnu/libpthread-2.19.so 7f56e4806000-7f56e4a05000 ---p 00019000 08:02 4195432 /lib/x86_64-linux-gnu/libpthread-2.19.so 7f56e4a05000-7f56e4a06000 r--p 00018000 08:02 4195432 /lib/x86_64-linux-gnu/libpthread-2.19.so 7f56e4a06000-7f56e4a07000 rw-p 00019000 08:02 4195432 /lib/x86_64-linux-gnu/libpthread-2.19.so 7f56e4a07000-7f56e4a0b000 rw-p 00000000 00:00 0 7f56e4a0b000-7f56e4bc5000 r-xp 00000000 08:02 4198551 /lib/x86_64-linux-gnu/libc-2.19.so 7f56e4bc5000-7f56e4dc5000 ---p 001ba000 08:02 4198551 /lib/x86_64-linux-gnu/libc-2.19.so 7f56e4dc5000-7f56e4dc9000 r--p 001ba000 08:02 4198551 /lib/x86_64-linux-gnu/libc-2.19.so 7f56e4dc9000-7f56e4dcb000 rw-p 001be000 08:02 4198551 /lib/x86_64-linux-gnu/libc-2.19.so 7f56e4dcb000-7f56e4dd0000 rw-p 00000000 00:00 0 7f56e4dd0000-7f56e4ed6000 r-xp 00000000 08:02 8135222 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22 7f56e4ed6000-7f56e50d5000 ---p 00106000 08:02 8135222 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22 7f56e50d5000-7f56e50dd000 r--p 00105000 08:02 8135222 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22 7f56e50dd000-7f56e50df000 rw-p 0010d000 08:02 8135222 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22 7f56e50df000-7f56e50e2000 rw-p 00000000 00:00 0 7f56e50e2000-7f56e50f9000 r-xp 00000000 08:02 8150271 /usr/lib/libfdfsclient.so 7f56e50f9000-7f56e52f9000 ---p 00017000 08:02 8150271 /usr/lib/libfdfsclient.so 7f56e52f9000-7f56e52fa000 r--p 00017000 08:02 8150271 /usr/lib/libfdfsclient.so 7f56e52fa000-7f56e52fb000 rw-p 00018000 08:02 8150271 /usr/lib/libfdfsclient.so 7f56e52fb000-7f56e531e000 r-xp 00000000 08:02 4195434 /lib/x86_64-linux-gnu/ld-2.19.so 7f56e54fd000-7f56e5504000 rw-p 00000000 00:00 0 7f56e551a000-7f56e551d000 rw-p 00000000 00:00 0 7f56e551d000-7f56e551e000 r--p 00022000 08:02 4195434 /lib/x86_64-linux-gnu/ld-2.19.so 7f56e551e000-7f56e551f000 rw-p 00023000 08:02 4195434 /lib/x86_64-linux-gnu/ld-2.19.so 7f56e551f000-7f56e5520000 rw-p 00000000 00:00 0 7ffe370f2000-7ffe37113000 rw-p 00000000 00:00 0 [stack] 7ffe3711d000-7ffe3711f000 r--p 00000000 00:00 0 [vvar] 7ffe3711f000-7ffe37121000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] Aborted (core dumped)

happyfish100 commented 6 years ago

you should call log_init() first. such as:

log_init(); auto result = fdfs_client_init("/etc/fdf/client.conf");