From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,582dff0b3f065a52 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,bc1361a952ec75ca X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,582dff0b3f065a52 X-Google-Attributes: gid1014db,public X-Google-ArrivalTime: 2001-08-16 12:30:24 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!titan03.ksc.nasa.gov!niven.ksc.nasa.gov!usenet From: "Samuel T. Harris" Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++ Subject: Re: How Ada could have prevented the Red Code distributed denial of service attack. Date: Thu, 16 Aug 2001 14:28:50 -0500 Organization: Raytheon Aerospace Engineering Services Message-ID: <3B7C1EF2.4DF3C7A5@gsde.hou.us.ray.com> References: <3b690498.1111845720@news.worldonline.nl> <9kbu15$9bj@augusta.math.psu.edu> <9kbvsr$a02@augusta.math.psu.edu> <3B69DB35.4412459E@home.com> <3B6F312F.DA4E178E@home.com> <23lok9.ioi.ln@10.0.0.2> <3B70AB15.35845A98@home.com> <3B721FF5.B7D854F6@home.com> <3B7BC847.61D7EF55@home.com> Reply-To: samuel_t_harris@raytheon.com NNTP-Posting-Host: sstf-fw.jsc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (X11; U; IRIX64 6.2 IP19) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:12007 comp.lang.c:74799 comp.lang.c++:83186 Date: 2001-08-16T14:28:50-05:00 List-Id: Kaz Kylheku wrote: > > In article <3B7BC847.61D7EF55@home.com>, Warren W. Gay VE3WWG wrote: > >David Thompson wrote: > >> Warren W. Gay VE3WWG wrote : > >> ... > >> > I wasn't talking abuse. On 5 different platforms, the sizeof "ab" could > >> > yeild the answers 3,4 or 8, depending upon the platforms chosen ;-) > >> > This is not a very good result for such a simple compiler request. > >> > > >> Not true. In any conforming implementation of either C or C++ > >> sizeof "ab" is 3. Perhaps you meant one of two other things: > > > >Maybe that's now true with the C99 standard. But it is definitely > > sizeof "ab" == 3 is a C89 feature. I don't have a copy of K&R 1978 > but I'd be surprised if it did not document this as well. > > >_not true_ of _many_ existing pre-C99 compilers! > > Could you name one? I do have my 1978 K&R handy and it is indeed ambiguous as to whether or not the zero value automatically appended after a string constant should or should not be counted by size_of. The definition of size_of discusses the "size" of an object while a string constant is defined as a sequence of chars between quotes. A zero value which is appended after or at the end the string by the compiler. Is is unclear as to whether or not the zero value is considered part of the string constant. There is a discussion of the difference between 'x' and "x" which stipulates that "x" uses storage for 'x' and a zero value. Note that this reference is _not_ part of the C Reference Manual section. This seems to indicate that the zero value is part of the storage of the string constant but size_of is not defined in terms of storage, but in terms of the size of an object. So, according to 1978 K&R, the value of size_of "ab" is indeed open to interpretation. -- Samuel T. Harris, Senior Software Engineer II Raytheon, Aerospace Engineering Services "If you can make it, We can fake it!"