Fix data comparison to not overrun array bounds.
This commit is contained in:
parent
aa1aaac03e
commit
3809e348e0
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: ping.c,v 1.53 1999/07/04 15:24:35 itojun Exp $ */
|
/* $NetBSD: ping.c,v 1.54 2000/01/20 01:04:41 mycroft Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1989, 1993
|
* Copyright (c) 1989, 1993
|
||||||
@ -62,7 +62,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
__RCSID("$NetBSD: ping.c,v 1.53 1999/07/04 15:24:35 itojun Exp $");
|
__RCSID("$NetBSD: ping.c,v 1.54 2000/01/20 01:04:41 mycroft Exp $");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -1012,14 +1012,14 @@ pr_pack(u_char *buf,
|
|||||||
&opack_icmp.icmp_data[PHDR_LEN],
|
&opack_icmp.icmp_data[PHDR_LEN],
|
||||||
datalen-PHDR_LEN)) {
|
datalen-PHDR_LEN)) {
|
||||||
for (i=PHDR_LEN; i<datalen; i++) {
|
for (i=PHDR_LEN; i<datalen; i++) {
|
||||||
if (icp->icmp_data[PHDR_LEN+i]
|
if (icp->icmp_data[i] !=
|
||||||
!= opack_icmp.icmp_data[PHDR_LEN+i])
|
opack_icmp.icmp_data[i])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PR_PACK_SUB();
|
PR_PACK_SUB();
|
||||||
(void)printf("\nwrong data byte #%d should have been"
|
(void)printf("\nwrong data byte #%d should have been"
|
||||||
" %#x but was %#x",
|
" %#x but was %#x", i,
|
||||||
i, (u_char)opack_icmp.icmp_data[i],
|
(u_char)opack_icmp.icmp_data[i],
|
||||||
(u_char)icp->icmp_data[i]);
|
(u_char)icp->icmp_data[i]);
|
||||||
for (i=PHDR_LEN; i<datalen; i++) {
|
for (i=PHDR_LEN; i<datalen; i++) {
|
||||||
if ((i%16) == PHDR_LEN)
|
if ((i%16) == PHDR_LEN)
|
||||||
|
Loading…
Reference in New Issue
Block a user