Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve compilation warnings #69

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gethostname.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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");
}
}
}
4 changes: 2 additions & 2 deletions rtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion sendicmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down