tavenzhang / protoc-gen-as3

Automatically exported from code.google.com/p/protoc-gen-as3
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Negative int32 issues #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Have a protocol with a message containing one int32
2. Send one such message with a negative value for the int, for instance 
the Java implementation
3. Try to decode it in AS3

What is the expected output? What do you see instead?

The message should be properly decoded (int32 is allowed to take negative 
values) but crashes the lib instead. This seems to come from the assumption 
that int32 are positive made by the lib. I'm looking into fixing it, but 
feedback would be welcome.

Please provide any additional information below.

Original issue reported on code.google.com by axelle.z...@gmail.com on 9 Feb 2010 at 4:26

GoogleCodeExporter commented 9 years ago
The problem seems to be partially fixed by reading up to 64 bits when reading 
an int32 
(since that's what the protobuf implementation seems to be doing anyway). 
However that 
still won't work for large negative numbers (I suspect it's because they 
overflow 
uint).

Original comment by axelle.z...@gmail.com on 9 Feb 2010 at 5:17

GoogleCodeExporter commented 9 years ago
After a wider bit of investigation, the problem comes from the fact that 32bits 
negative integers actually are 10 bytes long, and thus indeed overflow uint. 
Reading 
them partially and shifting them after that should work, I'm currently working 
on a new 
implementation of varintreader. Let me know if you're interested in the patch

Original comment by axelle.z...@gmail.com on 11 Feb 2010 at 6:41

GoogleCodeExporter commented 9 years ago
Thanks. This issue is now fixed.

Original comment by pop.atry@gmail.com on 21 Feb 2010 at 6:39