Closed
Description
Originally reported on Google Code with ID 345
The attached patch shows what is wrong with the BE code.
The original code goes from the address of p_value p_nb_bytes to
the right. From there it copies p_nb_bytes into the buffer.
The patched code goes from the address of p_value sizeof(OPJ_UINT32)
to the right and from there p_nb_bytes back. From there it copies
p_nb_bytes into the buffer.
The patched code has been proved to be correct on a G5 machine
working with Debian ppc64 code.
winfried
--- cio.c.orig 2014-04-26 01:12:48.653018821 +0000
+++ cio.c 2014-04-26 02:48:24.823047287 +0000
@@ -46,11 +46,11 @@
void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes)
{
- const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + p_nb_bytes;
+ const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value);
assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
- memcpy(p_buffer,l_data_ptr,p_nb_bytes);
+ memcpy(p_buffer,l_data_ptr+sizeof(OPJ_UINT32)-p_nb_bytes,p_nb_bytes);
}
void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes)
Reported by szukw000 on 2014-05-11 15:12:11