Andy Ross writes:
> There *is* an endian dependence in Nasal. There's a comment at the
> top of nasal.h. Basically, Nasal's pass-by-value "naRef" type stores
> either a pointer to a garbage-collected object, *or* a double. It
> tells the difference by putting a magic number in the unused half of
> the double. This value is crafted such that it makes the double look
> like a NaN, which can never result from a valid computation. But to
> do that, it needs to live in the "top" half of the double, which
> depends on the endianness of the processor. It is correct as written
> for little-endian 32 bit and all 64 bit systems. Big-endian 32 bit
> architectures like MIPS32 should swap the order of components in the
> naRef structure.
>
> In some circumstance (albeit not FlightGear), this can be a terrible
> security hole -- an attacker could create a fancy number with the
> right values in the bottom bits and cause the interpreter to derefence
> memory pointed to by the top half. But I don't think this is what is
> causing your problem. The likelihood of actually seeing such a number
> in practice is almoze zero (maybe exactly zero in this case -- the
> test.nas script uses only integer math). And in such a case, of
> course, you are exceedingly unlikely to hit valid memory; you'd almost
> certainly just crash.
>
> Anyway, try setting the NASAL_BIG_ENDIAN_32BIT #define at the top of
> nasal.h. It probably won't help, but it's the Right Thing to do. We
> need to detect this automatically. SimGear doesn't have an existing
> endianness test; is there a semi-standard autoconf way of doing this?
> At worst, we could just build a big tree of #if's for every
> architecture we support. Ugly, though.
>
> But I have a few bugfixes queued up. I *think* all of them should
> have been deterministic across architectures. But you never know.
> Give me a few hours to put together another code drop.
I believe that plib has some endiannes tests. Also simgear, have a
look at simgear/io/lowlevel.hxx (towards the end)
inline bool sgIsLittleEndian() {
static const int sgEndianTest = 1;
return (*((char *) &sgEndianTest ) != 0);
}
inline bool sgIsBigEndian() {
static const int sgEndianTest = 1;
return (*((char *) &sgEndianTest ) == 0);
}
Regards,
Curt.
--
Curtis Olson HumanFIRST Program FlightGear Project
Twin Cities curt 'at' me.umn.edu curt 'at' flightgear.org
Minnesota http://www.flightgear.org/~curt http://www.flightgear.org
_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel