Coredump-N: C pclose core dump

pclose -> fclose,这个函数没有对传进来的参数做判断直接使用,所以如果传入的参数是空指针,导致coredump

#0 0x00007ffff009c0d4 in fclose@@GLIBC_2.2.5 () from /lib64/libc.so.6
(gdb) disass
Dump of assembler code for function fclose@@GLIBC_2.2.5:
0x00007ffff009c0d0 <+0>: push %r12
0x00007ffff009c0d2 <+2>: push %rbp
0x00007ffff009c0d3 <+3>: push %rbx
=> 0x00007ffff009c0d4 <+4>: mov (%rdi),%edx

(gdb) bt
#0 0x00007ffff009c0d4 in fclose@@GLIBC_2.2.5 () from /lib64/libc.so.6

65 FILE *out = popen(“abc", “r”);
67 pclose(out); 如果这里不做判断,很有可能传进去一个非法值。

猜你喜欢

转载自blog.csdn.net/qq_36428903/article/details/125569870