diff --git a/gethostname.c b/gethostname.c index 97015ef..1646843 100644 --- a/gethostname.c +++ b/gethostname.c @@ -34,7 +34,7 @@ char *get_hostname(char* addr) if (!strcmp(addr, lastreq)) return last_answerp; - strncpy(lastreq, addr, 1024); + strncpy(lastreq, addr, 1023); inet_aton(addr, &naddr); he = gethostbyaddr((char*)&naddr, 4, AF_INET); @@ -43,7 +43,7 @@ char *get_hostname(char* addr) return NULL; } - strncpy(answer, he->h_name, 1024); + strncpy(answer, he->h_name, 1023); last_answerp = answer; return answer; diff --git a/listen.c b/listen.c index 2a73c43..4f18b80 100644 --- a/listen.c +++ b/listen.c @@ -27,6 +27,7 @@ void listenmain(void) int stdoutFD = fileno(stdout); char packet[IP_MAX_SIZE+linkhdr_size]; char *p, *ip_packet; + ssize_t bytes_written; struct myiphdr ip; __u16 id; static __u16 exp_id; /* expected id */ @@ -74,7 +75,9 @@ void listenmain(void) } p+=strlen(sign); - write(stdoutFD, p, size-(p-ip_packet)); + bytes_written = write(stdoutFD, p, size-(p-ip_packet)); + if (bytes_written == -1) + fprintf(stderr, "Unable to send packet\n"); } } } diff --git a/rtt.c b/rtt.c index e06343d..57fc309 100644 --- a/rtt.c +++ b/rtt.c @@ -45,8 +45,8 @@ int rtt(int *seqp, int recvport, float *ms_delay) tablepos = i; break; } - if (i != TABLESIZE) - *seqp = delaytable[i].seq; + if (i != TABLESIZE) + *seqp = delaytable[i].seq; } if (tablepos != -1) diff --git a/sendicmp.c b/sendicmp.c index 7efb274..ed4968b 100644 --- a/sendicmp.c +++ b/sendicmp.c @@ -253,7 +253,7 @@ void send_icmp_other(void) /* fill IP */ if (left_space == 0) goto no_space_left; - memcpy(packet+ICMPHDR_SIZE, &icmp_ip, left_space); + memcpy(packet+ICMPHDR_SIZE, &icmp_ip, ICMPHDR_SIZE); left_space -= IPHDR_SIZE; data += IPHDR_SIZE; if (left_space <= 0) goto no_space_left;