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: 1014db,582dff0b3f065a52 X-Google-Attributes: gid1014db,public X-Google-Thread: 109fba,582dff0b3f065a52 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,bc1361a952ec75ca X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-16 15:23:51 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!howland.erols.net!panix!news.panix.com!panix3.panix.com!not-for-mail From: comeau@panix.com (Greg Comeau) 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: 16 Aug 2001 18:23:50 -0400 Organization: Comeau Computing; http://www.comeaucomputing.com Message-ID: <9lhh5m$5r9$1@panix3.panix.com> References: <3B7BC847.61D7EF55@home.com> <3B7BCEC4.202A3FA@cfmu Reply-To: comeau@comeaucomputing.com NNTP-Posting-Host: panix3.panix.com X-Trace: news.panix.com 998000630 10175 166.84.1.3 (16 Aug 2001 22:23:50 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: 16 Aug 2001 22:23:50 GMT Xref: archiver1.google.com comp.lang.ada:12019 comp.lang.c:74865 comp.lang.c++:83258 Date: 2001-08-16T22:23:50+00:00 List-Id: In article , Karthik Gurusamy wrote: >If I have > char title[] = "hello world!"; > >Is sizeof title guaranteed to be 13 (strlen("hello world!) + 1)? Assuming we're talking about Standard C or Standard C++ and assuming we're talking about the exact code sample above, then that's the semantics each apply to the above. >Can it ever happen sizeof title is more than 13? Not according to Standard C or Standard C++. Broken compilers, or compiler with extensions are another matter, though that said, I haven't seen any getting this wrong. BTW, there is no "identity" that sizeof "SomeChars" is the same as strlen("SomeChar")+1, because it may contain null bytes. -- Greg Comeau Countdown to "export": December 1, 2001 Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90. Comeau C/C++ with Dinkumware's Libraries. Have you tried it?