View | Details | Raw Unified | Return to bug 239975 | Differences between
and this patch

Collapse All | Expand All

(-)sbin/ping/ping.c (-2 / +2 lines)
Lines 1048-1060 Link Here
1048
	cc = ICMP_MINLEN + phdr_len + datalen;
1048
	cc = ICMP_MINLEN + phdr_len + datalen;
1049
1049
1050
	/* compute ICMP checksum here */
1050
	/* compute ICMP checksum here */
1051
	icp->icmp_cksum = in_cksum((u_char *)icp, cc);
1051
	icp->icmp_cksum = in_cksum((u_char *)icp, sizeof(struct ip), IP_MAXPACKET, cc);
1052
1052
1053
	if (options & F_HDRINCL) {
1053
	if (options & F_HDRINCL) {
1054
		cc += sizeof(struct ip);
1054
		cc += sizeof(struct ip);
1055
		ip = (struct ip *)outpackhdr;
1055
		ip = (struct ip *)outpackhdr;
1056
		ip->ip_len = htons(cc);
1056
		ip->ip_len = htons(cc);
1057
		ip->ip_sum = in_cksum(outpackhdr, cc);
1057
		ip->ip_sum = in_cksum(outpackhdr, sizeof(struct ip), IP_MAXPACKET, cc);
1058
		packet = outpackhdr;
1058
		packet = outpackhdr;
1059
	}
1059
	}
1060
	i = send(ssend, (char *)packet, cc, 0);
1060
	i = send(ssend, (char *)packet, cc, 0);
(-)sbin/ping/utils.c (-2 / +2 lines)
Lines 55-61 Link Here
55
 *	Checksum routine for Internet Protocol family headers (C Version)
55
 *	Checksum routine for Internet Protocol family headers (C Version)
56
 */
56
 */
57
u_short
57
u_short
58
in_cksum(u_char *addr, int len)
58
in_cksum(u_char *addr, size_t ipstructsize, int ip_maxpacket, int len)
59
{
59
{
60
	int nleft, sum;
60
	int nleft, sum;
61
	u_char *w;
61
	u_char *w;
Lines 74-80 Link Here
74
	 * sequential 16 bit words to it, and at the end, fold back all the
74
	 * sequential 16 bit words to it, and at the end, fold back all the
75
	 * carry bits from the top 16 bits into the lower 16 bits.
75
	 * carry bits from the top 16 bits into the lower 16 bits.
76
	 */
76
	 */
77
	while (nleft > 1)  {
77
	while ((nleft > 1) && (w < &addr[ip_maxpacket - ipstructsize - sizeof(u_short)]))  {
78
		u_short data;
78
		u_short data;
79
79
80
		memcpy(&data, w, sizeof(data));
80
		memcpy(&data, w, sizeof(data));
(-)sbin/ping/utils.h (-1 / +1 lines)
Lines 33-38 Link Here
33
33
34
#include <sys/types.h>
34
#include <sys/types.h>
35
35
36
u_short in_cksum(u_char *, int);
36
u_short in_cksum(u_char *, size_t, int, int);
37
37
38
#endif
38
#endif

Return to bug 239975