Re: Possible memory fault in pinger

From: Evgeny Kotsuba <evgen__k@dont-contact.us>
Date: Fri, 16 Apr 2004 16:54:22 +0400

On Fri, 16 Apr 2004 11:23:02 +0200 (CEST)
  Henrik Nordstrom <hno@squid-cache.org> wrote:
>On Fri, 16 Apr 2004, Evgeny Kotsuba wrote:
>
>> Hi,
>> Squid 2.5 and Squid 3
>> file pinger.c/pinger.cc, function pingerSendEcho()
>> 1)
>> I have
>> //MAX_PKT_SZ=294, sizeof(pkt)=294, sizeof(struct
>> icmhdr)=28,sizeof(icmpEchoData)=268,
>> //28+268=296 > 294!
>
>
>Eh? The size of MAX_PKT_SZ is dependent on MAX_PAYLOAD to make sure
>the
>packet is sufficiently large.
>
>If you manually set MAX_PKT_SZ to something else then you must change
>all
>code building the packet. The code is not designed with this in mind.
We have

#if ALLOW_SOURCE_PING
#define MAX_PKT_SZ 8192
#define MAX_PAYLOAD (MAX_PKT_SZ - sizeof(struct icmphdr) - sizeof
(char) - sizeof(struct timeval) - 1)
#else
#define MAX_PAYLOAD SQUIDHOSTNAMELEN
#define MAX_PKT_SZ (MAX_PAYLOAD + sizeof(struct timeval) + sizeof
(char) + sizeof(struct icmphdr) + 1)
#endif

The ALLOW_SOURCE_PING is not defined anywere so MAX_PAYLOAD is
SQUIDHOSTNAMELEN, and SQUIDHOSTNAMELEN in my case is equal to 256

And I want say only one simple thiing - that due to stucture alingment
the sizeof(struct icmpEchoData) may not be equal to sizeof(struct
timeval) + sizeof (char) + MAX_PAYLOAD, so that the MAX_PKT_SZ
  should be

#define MAX_PKT_SZ (MAX_PAYLOAD + sizeof(struct timeval) + sizeof
(char) + sizeof(struct icmphdr) + 1 +4)

to ensure that we will not have any problems

SY,
Evgeny Kotsuba
Received on Fri Apr 16 2004 - 07:58:27 MDT

This archive was generated by hypermail pre-2.1.9 : Thu Apr 29 2004 - 12:00:03 MDT