projects
/
liboping.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed wrong icmp header length (20 extra zeros incorrectly appended to header)
[liboping.git]
/
src
/
liboping.c
diff --git
a/src/liboping.c
b/src/liboping.c
index
dd9da46
..
396f489
100644
(file)
--- a/
src/liboping.c
+++ b/
src/liboping.c
@@
-1,6
+1,6
@@
/**
* Object oriented C module to send ICMP and ICMPv6 `echo's.
/**
* Object oriented C module to send ICMP and ICMPv6 `echo's.
- * Copyright (C) 2006-201
1
Florian octo Forster <ff at octo.it>
+ * Copyright (C) 2006-201
6
Florian octo Forster <ff at octo.it>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
@@
-298,12
+298,12
@@
static pinghost_t *ping_receive_ipv4 (pingobj_t *obj, char *buffer,
buffer += ip_hdr_len;
buffer_len -= ip_hdr_len;
buffer += ip_hdr_len;
buffer_len -= ip_hdr_len;
- if (buffer_len < sizeof (struct icmp))
+ if (buffer_len < sizeof (struct icmp
hdr
))
return (NULL);
icmp_hdr = (struct icmp *) buffer;
return (NULL);
icmp_hdr = (struct icmp *) buffer;
- buffer += sizeof (struct icmp);
- buffer_len -= sizeof (struct icmp);
+ buffer += sizeof (struct icmp
hdr
);
+ buffer_len -= sizeof (struct icmp
hdr
);
if (icmp_hdr->icmp_type != ICMP_ECHOREPLY)
{
if (icmp_hdr->icmp_type != ICMP_ECHOREPLY)
{
@@
-314,7
+314,7
@@
static pinghost_t *ping_receive_ipv4 (pingobj_t *obj, char *buffer,
recv_checksum = icmp_hdr->icmp_cksum;
icmp_hdr->icmp_cksum = 0;
calc_checksum = ping_icmp4_checksum ((char *) icmp_hdr,
recv_checksum = icmp_hdr->icmp_cksum;
icmp_hdr->icmp_cksum = 0;
calc_checksum = ping_icmp4_checksum ((char *) icmp_hdr,
- sizeof (struct icmp) + buffer_len);
+ sizeof (struct icmp
hdr
) + buffer_len);
if (recv_checksum != calc_checksum)
{
if (recv_checksum != calc_checksum)
{
@@
-825,7
+825,7
@@
static int ping_send_one_ipv4 (pingobj_t *obj, pinghost_t *ph)
memset (buf, '\0', sizeof (buf));
icmp4 = (struct icmp *) buf;
memset (buf, '\0', sizeof (buf));
icmp4 = (struct icmp *) buf;
- data =
(char *) (icmp4 + 1
);
+ data =
buf + sizeof (struct icmphdr
);
icmp4->icmp_type = ICMP_ECHO;
icmp4->icmp_code = 0;
icmp4->icmp_type = ICMP_ECHO;
icmp4->icmp_code = 0;
@@
-833,11
+833,11
@@
static int ping_send_one_ipv4 (pingobj_t *obj, pinghost_t *ph)
icmp4->icmp_id = htons (ph->ident);
icmp4->icmp_seq = htons (ph->sequence);
icmp4->icmp_id = htons (ph->ident);
icmp4->icmp_seq = htons (ph->sequence);
- buflen =
4096 - sizeof (struct icmp
);
+ buflen =
sizeof(buf) - sizeof (struct icmphdr
);
strncpy (data, ph->data, buflen);
datalen = strlen (data);
strncpy (data, ph->data, buflen);
datalen = strlen (data);
- buflen = datalen + sizeof (struct icmp);
+ buflen = datalen + sizeof (struct icmp
hdr
);
icmp4->icmp_cksum = ping_icmp4_checksum (buf, buflen);
icmp4->icmp_cksum = ping_icmp4_checksum (buf, buflen);