bonjour
j'ai programmé un simple code utilisant deux popen mai le problème que l'un s'exécute correctement et l'autre nom voici le code et le message d'erreur
voici après compilation et exécution
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 #include <iostream> #include <fstream> #include <iterator> #include <algorithm> #include <vector> #include <string> #include <cstring> int main(int argc, char* argv[]) { std::string comm; comm = "ipsumdump -r "; comm +=argv[1]; comm +=" --no-headers -f 'tcp[13] == 2' -sSdD >FS.txt"; size_t size = comm.size() + 1; char * buffer = new char[ size ]; strncpy( buffer, comm.c_str(), size ); FILE *flux = popen(buffer,"r"); pclose(flux); std::cout<<"traitemnt fini FS.txt"<<std::endl; std::cout<<"traitemnt debut FSA.txt"<<std::endl; comm = "ipsumdump -r "; comm +=argv[1]; comm +=" --no-headers -f 'tcp[13] == 18' -dDsS >FSA.txt"; size_t size1 = comm.size() + 1; char * buffer1 = new char[ size ]; strncpy( buffer1, comm.c_str(), size1 ); FILE *flux1 = popen(buffer1,"r"); pclose(flux1); return 1; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 100% |******************************************************************************************************************************| 184MB 00:14 traitemnt fini FS.txt traitemnt debut FSA.txt *** glibc detected *** ./Test: malloc(): memory corruption: 0x09d58060 *** ======= Backtrace: ========= /lib/libc.so.6[0x7b0006] /lib/libc.so.6(__libc_malloc+0x95)[0x7b1755] /lib/libc.so.6(popen+0x21)[0x79f1c1] ./Test[0x8048af1] /lib/libc.so.6(__libc_start_main+0xe5)[0x7546d5] ./Test[0x8048861] ======= Memory map: ======== 00110000-00111000 r-xp 00110000 00:00 0 [vdso] 00120000-00207000 r-xp 00000000 fd:00 730611 /usr/lib/libstdc++.so.6.0.10 00207000-0020b000 r--p 000e6000 fd:00 730611 /usr/lib/libstdc++.so.6.0.10 0020b000-0020d000 rw-p 000ea000 fd:00 730611 /usr/lib/libstdc++.so.6.0.10 0020d000-00212000 rw-p 0020d000 00:00 0 00719000-00739000 r-xp 00000000 fd:00 1207236 /lib/ld-2.9.so 0073a000-0073b000 r--p 00020000 fd:00 1207236 /lib/ld-2.9.so 0073b000-0073c000 rw-p 00021000 fd:00 1207236 /lib/ld-2.9.so 0073e000-008ac000 r-xp 00000000 fd:00 1207237 /lib/libc-2.9.so 008ac000-008ae000 r--p 0016e000 fd:00 1207237 /lib/libc-2.9.so 008ae000-008af000 rw-p 00170000 fd:00 1207237 /lib/libc-2.9.so 008af000-008b2000 rw-p 008af000 00:00 0 008b4000-008db000 r-xp 00000000 fd:00 1207243 /lib/libm-2.9.so 008db000-008dc000 r--p 00026000 fd:00 1207243 /lib/libm-2.9.so 008dc000-008dd000 rw-p 00027000 fd:00 1207243 /lib/libm-2.9.so 00dca000-00dd7000 r-xp 00000000 fd:00 1207250 /lib/libgcc_s-4.3.2-20081105.so.1 00dd7000-00dd8000 rw-p 0000c000 fd:00 1207250 /lib/libgcc_s-4.3.2-20081105.so.1 08048000-08049000 r-xp 00000000 fd:00 213082 /home/anis/BloomFilter_-_CPP/Test 08049000-0804a000 rw-p 00000000 fd:00 213082 /home/anis/BloomFilter_-_CPP/Test 09d58000-09d79000 rw-p 09d58000 00:00 0 [heap] b7f00000-b7f21000 rw-p b7f00000 00:00 0 b7f21000-b8000000 ---p b7f21000 00:00 0 b80c5000-b80c8000 rw-p b80c5000 00:00 0 b80e3000-b80e4000 rw-p b80e3000 00:00 0 bfece000-bfee3000 rw-p bffeb000 00:00 0 [stack] Aborted
Partager