Author: Jens Thoms ToerringJens Thoms Toerring Date: May 6, 2008 01:59
> I have found a major flaw in a CPAN package. The package is
> File::Binary and it has big endian and little endian unpack-ing
> backwards. Likewise, all the test files are reversed so that the
> tests all pass!
> Why do I believe this is true?
> From the perl manual on pack:
> n,N unpacks a 16 or 32 bit integer in "network" or big endian order
> v,V unpacks a 16 or 32 bit integer in "VAX" or little endian order
> From the code:
> if ($endian == $BIG_ENDIAN) {
> $self->{_ui16} = 'v';
> $self->{_ui32} = 'V';
> } else {
> $self->{_ui16} = 'n';
> $self->{_ui32} = 'N';
> }
> When I 'od -x' the test files, they are clearly reversed:
|