digideskio / protobuf-c

Automatically exported from code.google.com/p/protobuf-c
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

protobuf-c.c:required_field_pack_to_buffer() is broken on big endian platforms #29

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
on big endian platforms the protobuf-c test suite fails, e.g.:

> Test: test required sfixed32... test_versus_static_array failed:
> actual: [length=6]
>  a5 06 70 a7 bf bf
> expected: [length=6] [buffer test_required_sfixed32_min]
>  a5 06 00 00 00 80
> at line 235 of test-generated-code2.c.

or

> Test: test required sfixed32... test_versus_static_array failed:
> actual: [length=6]
>  a5 06 48 60 43 00
> expected: [length=6] [buffer test_required_sfixed32_min]
>  a5 06 00 00 00 80
> at line 235 of test-generated-code2.c.

or

> Test: test required sfixed32... Bus error

the problem is that required_field_pack_to_buffer() attempts to 
dereference the void *member parameter as a uint64_t pointer when member 
points to a 32 bit quantity. this happens to work on little endian 
platforms but not on big endian platforms.

the attached patch fixes this.

Original issue reported on code.google.com by robert.e...@gmail.com on 11 Nov 2009 at 2:58

Attachments:

GoogleCodeExporter commented 8 years ago
it looks like this problem also exists in required_field_pack()

Original comment by robert.e...@gmail.com on 11 Nov 2009 at 4:47

GoogleCodeExporter commented 8 years ago
here is the patch used in the debian protobuf-c 0.11-3 package.

Original comment by robert.e...@gmail.com on 12 Nov 2009 at 7:08

Attachments:

GoogleCodeExporter commented 8 years ago
the patch has been applied and is in protobuf-c 0.12.

Original comment by lahike...@gmail.com on 24 Jan 2010 at 5:01