Deal with a case where the returned packed was smaller than the
transmitted packet (because the remote host stripped off our icmp_data). Submitted by: Maxim Konovalov <maxim@macomnet.ru>
This commit is contained in:
parent
5c514aeee8
commit
47e9b3ea64
@ -955,17 +955,20 @@ pr_pack(buf, cc, from, tv)
|
|||||||
#endif
|
#endif
|
||||||
tp += phdr_len;
|
tp += phdr_len;
|
||||||
|
|
||||||
/* Copy to avoid alignment problems: */
|
if (cc - ICMP_MINLEN - phdr_len >= sizeof(tv1)) {
|
||||||
memcpy(&tv1, tp, sizeof(tv1));
|
/* Copy to avoid alignment problems: */
|
||||||
tvsub(tv, &tv1);
|
memcpy(&tv1, tp, sizeof(tv1));
|
||||||
triptime = ((double)tv->tv_sec) * 1000.0 +
|
tvsub(tv, &tv1);
|
||||||
((double)tv->tv_usec) / 1000.0;
|
triptime = ((double)tv->tv_sec) * 1000.0 +
|
||||||
tsum += triptime;
|
((double)tv->tv_usec) / 1000.0;
|
||||||
tsumsq += triptime * triptime;
|
tsum += triptime;
|
||||||
if (triptime < tmin)
|
tsumsq += triptime * triptime;
|
||||||
tmin = triptime;
|
if (triptime < tmin)
|
||||||
if (triptime > tmax)
|
tmin = triptime;
|
||||||
tmax = triptime;
|
if (triptime > tmax)
|
||||||
|
tmax = triptime;
|
||||||
|
} else
|
||||||
|
timing = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
seq = ntohs(icp->icmp_seq);
|
seq = ntohs(icp->icmp_seq);
|
||||||
@ -1008,7 +1011,9 @@ pr_pack(buf, cc, from, tv)
|
|||||||
/* check the data */
|
/* check the data */
|
||||||
cp = (u_char*)&icp->icmp_data[phdr_len];
|
cp = (u_char*)&icp->icmp_data[phdr_len];
|
||||||
dp = &outpack[MINICMPLEN + phdr_len];
|
dp = &outpack[MINICMPLEN + phdr_len];
|
||||||
for (i = phdr_len; i < datalen; ++i, ++cp, ++dp) {
|
cc -= ICMP_MINLEN + phdr_len;
|
||||||
|
for (i = phdr_len; i < datalen && cc != 0;
|
||||||
|
++i, ++cp, ++dp, cc--) {
|
||||||
if (*cp != *dp) {
|
if (*cp != *dp) {
|
||||||
(void)printf("\nwrong data byte #%d should be 0x%x but was 0x%x",
|
(void)printf("\nwrong data byte #%d should be 0x%x but was 0x%x",
|
||||||
i, *dp, *cp);
|
i, *dp, *cp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user