[opensource-dev] Miscellaneous bad code in llviewerobject.cpp

Henri Beauchamp sldev at free.fr
Sat Sep 22 03:18:43 PDT 2018


On Fri, 21 Sep 2018 16:51:14 -0700, John Nagle wrote:

>     I've been looking for the "half-unsit" region crossing bug,
> adding debug code to llviewerobject.  Something is going wrong
> in reparenting, but I haven’t been able to isolate it yet.
> 
>     Looking in there, I've found some code that's wrong, but
> probably not causing trouble.
> 
> - Two possible buffer overflows. Reported to LL, being treated as
> a security issue.

It would be nice to share your findings with us too: LL is slow to fix
bugs in their code, and it will be weeks before we see the corresponding
commit appear in their repository...

> - Unchecked downcasts on polymorphic types. Those are risky.

Many such static downcasts are there because of the LLXform ->
LLPrimitive -> LLViewerObject inheritance. Since no code would
create LLPrimitive or LLXForm instances outside LLVierwerObject
inherited ones, the said static casts are safe, and much faster
(zero overhead) than dynamic casts (+ NULL check)...
But I agree that it is a bad practice and many such casts could be
avoided by moving some members to the LLXform class, such as using
an mIsAvatar boolean in LLXform, set by LLPrimitive inside setPCode(),
then moving isAvatar() from LLPrimitive to LLXform: this way, you can
test for avatar parent objects using mParent (which is a LLXform)
without having to donwcast... I just implemented this for my viewer.

> There's at least one place where an unexpected message from the sim
> will cause an invalid downcast. That's been reported to LL.

Again, it would be nice to share with us...

> (Does anybody still read this list?)

* raises his hand *

Regards,

Henri


More information about the opensource-dev mailing list