Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doubles[++i] = _byteStream.readDouble(); #122

Open
GoogleCodeExporter opened this issue Mar 13, 2016 · 3 comments
Open

doubles[++i] = _byteStream.readDouble(); #122

GoogleCodeExporter opened this issue Mar 13, 2016 · 3 comments

Comments

@GoogleCodeExporter
Copy link

I found a bug in AbstractAbcDeserializer.as as below.

doubles[++i] = _byteStream.readDouble();

This code should be read in little-endian order.
But the byteStream.endian was big-endian.

Original issue reported on code.google.com by [email protected] on 19 Apr 2012 at 2:56

@GoogleCodeExporter
Copy link
Author

Hi there,

you're not giving much information here. Where did the bytearray come from that 
you're trying to read? The deserializer doesn't change the incoming bytearray, 
it is assumed that the array is in big-endian order. So what do you mean 
precisely?

cheers,

Roland

Original comment by ihatelivelyids on 23 Apr 2012 at 9:38

@GoogleCodeExporter
Copy link
Author

Hi Roland

Sorry to be insufficient information. To modify abc data in a swf file, I got 
abc data (as a com.codeazur.as3swf.tags.TagDoABC class) from loaded swf file. 
Then I tried below codes.
  var abcDeserializer:AbcDeserializer = new AbcDeserializer(tagDoABC.bytes);
  var abcFile:AbcFile = abcDeserializer.deserialize();
  // some codes.
  var abcSerializer:AbcSerializer = new AbcSerializer();
  tagDoABC.bytes.length = 0;
  tagDoABC.bytes.writeBytes(abcSerializer.serializeAbcFile(abcFile));

Although no error was appeared, unexpected data were showed when I dumped the 
modified abc data like below.
  pushdouble 0.0235836493923 * 10^-69

The value was clearly wrong. So I checked the definition of double in AVM2 
overview.
http://www.adobe.com/content/dam/Adobe/en/devnet/actionscript/articles/avm2overv
iew.pdf

The overview saying that "Multi-byte primitive data are stored in little-endian 
order".

So I checked the deserialize method, and I found that _byteStream.readDouble() 
in line 144 of deserializeConstantPool method of AbstractAbcDeserializer class 
was performed in big-endian order.

Then I added below code just before readDouble method and the abnormal value 
was fixed.
  _byteStream.endian = Endian.LITTLE_ENDIAN;

I am using:
as3commons-bytecode-1.1.1.swc

Compiling with sdk 4.5

On Windows XP

Original comment by [email protected] on 23 Apr 2012 at 2:09

@GoogleCodeExporter
Copy link
Author

Hey there,

the serializer creates a ByteArray that has its endian property set to 
Endian.LITTLE_ENDIAN, so I'm guessing the the bytearray you receive from the 
as3swf library has been set to BIG_ENDIAN. Can you check that?
On my end I can't figure out what I could be doing wrong... I guess I could 
force the property on any incoming bytearrays to Endian.LITTLE_ENDIAN as well...

Roland

Original comment by ihatelivelyids on 24 Apr 2012 at 6:01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant