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.6 required=5.0 tests=BAYES_00,LOTS_OF_MONEY, TO_NO_BRKTS_FROM_MSSP 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: 1014db,582dff0b3f065a52 X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,bc1361a952ec75ca X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-07 10:16:29 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++ From: Ted Dennison 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> <3B6F5AAB.CF3A6ECA@home.com> Subject: Re: How Ada could have prevented the Red Code distributed denial of service attack. Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Tue, 07 Aug 2001 13:16:13 EDT Organization: http://www.newsranger.com Date: Tue, 07 Aug 2001 17:16:13 GMT Xref: archiver1.google.com comp.lang.ada:11510 comp.lang.c:72710 comp.lang.c++:80691 Date: 2001-08-07T17:16:13+00:00 List-Id: In article , Kaz Kylheku says... > >Your Ada wrapper could pass in a pointer to two bytes instead of >two integers. Great, so you have checking on the Ada side, but >what ensures that the cross-language-boundary hack is correct? Most of this stuff is not a *hack*. Its in the Ada standard. The Ada standard validation process ensures that the standards are upheld. >Does Ada even give you a type that is guaranteed to be the same >as the type int of the predominant C compiler of the same platform >as the language implementation? Yes it does: Interfaces.C.Int. It also gives you the capability of creating an integer type that is guaranteed to be the same number of bits reguardless of the platform, which C and C++ do not give you. >How do you *portably* declare, in Ada, a record type that >is precisely equivalent to POSIX struct termios from ? The version I have from cygwin just contains an include for sys/termios.h and 6 routine declarations. A portable binding to the routines would be trivial using the types in Interfaces.C (assuming the ".h" file itself is really portable, which with C is generally a bad assumption). The termios struct itself (in sys/termios.h) uses unsigned shorts, chars, and unsigned chars. All of those types are avilable for portable use in Interfaces.C. Thus making a binding that matches this *portably* would be trivial. It can be (and in some cases has been) generated by a translator program. >You ahve several problems there. The exact contents of the >structure a implementation-specific. Moreover, the way the struct >members are padded is also platform-specific. The second problem is a non-issue. If you apply "pragma Convention (C, foo);" to the declaration, its supposed to align the record the way C would align it. However, you are right that Ada can't guard against the possiblity that termios on another platform may not be the same struct. Ada that depends on C is indeed not portable when the C itself isn't portable (which unfortunately is just about always). If that's your point, I'd have to agree. That's why it pays to remove yourself from the C as far as possible. :-) However, if the differences in .h files don't affect the users much (which it doesn't, if you use the routines and macros), then C-forced changes in the innards of the Ada bindings won't affect the binding users much either (assuming they stuck to the provided routines, which you can *force* in Ada by making the record fields private). Think of Ada "bindings" as just the Ada equivalent of the C .h files you're accustomed to using for the same services. Most C compilers come with all the system .h file "bindings", and most Ada compilers come with all the system package "bindings". If the interface provided by C is reasonably portable, the Ada interface will be at least as portable. If the *implementation* provided by C is portable, the implementation provided by Ada can be made portable too. The system services themselves will work just as well either way. System services are machine code at this point, and won't ever know the difference. The only real difference is that you aren't stuck using C. :-) --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com