On Thu, Apr 24, 2014 at 11:44 PM, Steve Haflich <shaflich@gmail.com> wrote:
>
> On Thu, Apr 24, 2014 at 10:35 PM, Jean-Claude Beaudoin
> <jean.claude.beaudoin@gmail.com> wrote:
>>
>> On Fri, Apr 25, 2014 at 12:31 AM, Scott L. Burson <Scott@sympoiesis.com>
>> wrote:
>>>
>>> I've long thought that was an oversight, though now that you point it
>>> out, I realize I must have been mistaken.
>
> "Oversight" might be the wrong way of thinking about this. [...]
> We changed what _needed_ to be changed, cleaned
> up a lot of other inelegances, but there was not time or energy to attempt a
> thorough job. [...]
All I mean by "oversight" is that it was not the product of a
deliberate decision. From the tone of your previous message I thought
that it must have been deliberate, but now it sounds like I was
probably right the first time, though we don't know for sure.
>>> Still, it surprises me. I don't know of any implementation that
>>> doesn't bounds-check aref under normal speed/safety settings, and
>>> clearly, users expect them to do so.
>>
>> I am surprised too. I always understood it like you Scott but now that
>> re-read
>> the page on aref I see that it is exactly like Steve says, no mention of
>> any
>> exception and a statement that "subscripts" must be a list of valid array
>> indices
>> right from the start of the call to aref. Yet that leaves me even more
>> curious
>> to know which implementation has read the spec as strictly as Steve says
>> it can be even under (safety 3)? Does anyone know any?
>
> I don't know of any and there might not be any, at least among main-line
> implementations. [...]
>
> But in your paragraph above I'm bothered by its hidden assumption: It
> suggests that after the ANS was available sneaky implementors studied it
> kabalistically to find places where annoying error checks could be removed.
I don't read Jean-Claude this way. I think he was expressing surprise
at the thought that an implementor might have done that.
> To return to my important point, the language of the ANS wont let you read
> or write from a socket. At some point user application code will have to
> call some non-ANS functions, and in the real world those functions (just
> like C) will take a pointer into some overlarge buffer array along with a
> length, and that memory location will be passed further down to some system
> code (likely written in C) that has access to the entire user-space memory.
> Now, without the missing check on the length that allowed the Heartbleed
> bug, such an error won't allow buffer overruns in either input or output,
> but my point is that user C code and user CL code are little different in
> this regard.
It certainly is _possible_ to write an unsafe socket-write function
(*) in a CL library. But I still think the _probability_ of someone
doing so is substantially smaller in CL than in C. Writing in C is
like putting
(declaim (optimize (speed 3) (safety 0))) ; damn the torpedoes!!
at the top of every source file.
When writing a safety-0 function in CL, the unsafe region is much more
restricted, and one is more likely to be careful to add explicit
bounds checks where appropriate. (I recall only one occasion in my
career where I forgot to do this. Koff koff... but the point is, it's
not an error one has the opportunity to make very often.)
-- Scott
(* Actually the missing bounds check was on a 'memcpy' call that was
being used to prepare the heartbeat reply message, but the effect is
the same as if it had been on the socket write.)
_______________________________________________
pro mailing list
pro@common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/pro