Bonjour,
Voila je fais un petit code sur les raw sockets et voila , a la compilation , tous va bien seulement sa ne plait pas a valgrind qui me detecte quelque chose que je ne comprend pas !
Donc ont peut voir==8180== Syscall param socketcall.sendto(msg) points to uninitialised byte(s)
==8180== at 0x4000792: (within /lib/ld-2.3.6.so)
==8180== by 0x8049133: fn_thread_scan (in /home/marnage/s)
==8180== by 0x402E23F: start_thread (in /lib/tls/i686/cmov/libpthread-2.3.6.so)
==8180== by 0x410749D: clone (in /lib/tls/i686/cmov/libc-2.3.6.so)
==8180== Address 0x416E958 is 32 bytes inside a block of size 40 alloc'd
==8180== at 0x401C38B: malloc (vg_replace_malloc.c:149)
==8180== by 0x8049A04: init_struct (in /home/marnage/s)
==8180== by 0x804918A: scan_port (in /home/marnage/s)
==8180== by 0x8049133: fn_thread_scan (in /home/marnage/s)
==8180== by 0x402E23F: start_thread (in /lib/tls/i686/cmov/libpthread-2.3.6.so)
==8180== by 0x410749D: clone (in /lib/tls/i686/cmov/libc-2.3.6.so)
==8180== at 0x401C38B: malloc (vg_replace_malloc.c:149)
==8180== by 0x8049A04: init_struct (in /home/marnage/s)
Je dois comprendre qu'un malloc() dans cette fonction n'et pas bon?
Voila la fonction :
Personellement je ne vois pas se que valgrind lui trouve ... si quelqu'un aurait une piste ...
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
40
41
42
43 int init_struct(packet_t **packet) { *packet = NULL; *packet = (packet_t *) malloc(sizeof(packet_t)); if ( *packet == NULL ) { fprintf(stderr, "malloc() on packet failed\n"); return -1; } (*packet)->tcp = NULL; (*packet)->ip = NULL; (*packet)->fakehdr = NULL; (*packet)->pkt_send = NULL; (*packet)->pkt_recv = NULL; (*packet)->pkt_send = (char *) malloc(LEN_PACKET); if ( (*packet)->pkt_send == NULL ) { fprintf(stderr, "malloc() on pkt_send failed\n"); return -1; } (*packet)->ip = (iphdr_t *) (*packet)->pkt_send; if ( (*packet)->ip == NULL ) { fprintf(stderr, "ip value error\n"); return -1; } (*packet)->tcp = (tcphdr_t *) ((*packet)->pkt_send + sizeof(iphdr_t)); if ( (*packet)->tcp == NULL ) { fprintf(stderr, "ip value error\n"); return -1; } (*packet)->fakehdr = (fakehdr_t *) malloc(sizeof(fakehdr_t)); if ( (*packet)->fakehdr == NULL ) { fprintf(stderr, "malloc() on fakehdr failed\n"); return -1; } return 0; }
Voici la fonction sendto() a tout hasard :Et le paquet une fois envoyer est correcte ... .
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 if ( sendto(sock->s, packet->pkt_send, LEN_PACKET, 0, (struct sockaddr *)&sock->to, sizeof(sock->to)) == -1 )
Merci.
++
Partager