FS#12163 by Sean Bartell

get_long_be shifts an unsigned char left--which results in a signed int.
It then implicitly casts to unsigned long, which sign-extends the int,
leaving unwanted 1's in the upper bits. This affects AIFF.



git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30364 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2011-08-27 12:34:21 +00:00
parent 813b7623c1
commit 3aeb7fad9a
2 changed files with 12 additions and 12 deletions

View file

@ -155,7 +155,7 @@ uint64_t get_uint64_le(void* buf)
} }
/* Read an unaligned 32-bit little endian long from buffer. */ /* Read an unaligned 32-bit little endian long from buffer. */
unsigned long get_long_le(void* buf) uint32_t get_long_le(void* buf)
{ {
unsigned char* p = (unsigned char*) buf; unsigned char* p = (unsigned char*) buf;
@ -163,7 +163,7 @@ unsigned long get_long_le(void* buf)
} }
/* Read an unaligned 16-bit little endian short from buffer. */ /* Read an unaligned 16-bit little endian short from buffer. */
unsigned short get_short_le(void* buf) uint16_t get_short_le(void* buf)
{ {
unsigned char* p = (unsigned char*) buf; unsigned char* p = (unsigned char*) buf;
@ -171,7 +171,7 @@ unsigned short get_short_le(void* buf)
} }
/* Read an unaligned 32-bit big endian long from buffer. */ /* Read an unaligned 32-bit big endian long from buffer. */
unsigned long get_long_be(void* buf) uint32_t get_long_be(void* buf)
{ {
unsigned char* p = (unsigned char*) buf; unsigned char* p = (unsigned char*) buf;
@ -179,7 +179,7 @@ unsigned long get_long_be(void* buf)
} }
/* Read an unaligned 16-bit little endian short from buffer. */ /* Read an unaligned 16-bit little endian short from buffer. */
unsigned short get_short_be(void* buf) uint16_t get_short_be(void* buf)
{ {
unsigned char* p = (unsigned char*) buf; unsigned char* p = (unsigned char*) buf;
@ -187,14 +187,14 @@ unsigned short get_short_be(void* buf)
} }
/* Read an unaligned 32-bit little endian long from buffer. */ /* Read an unaligned 32-bit little endian long from buffer. */
long get_slong(void* buf) int32_t get_slong(void* buf)
{ {
unsigned char* p = (unsigned char*) buf; unsigned char* p = (unsigned char*) buf;
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
} }
unsigned long get_itunes_int32(char* value, int count) uint32_t get_itunes_int32(char* value, int count)
{ {
static const char hexdigits[] = "0123456789ABCDEF"; static const char hexdigits[] = "0123456789ABCDEF";
const char* c; const char* c;

View file

@ -59,11 +59,11 @@ int read_uint64be(int fd, uint64_t* buf);
#endif #endif
uint64_t get_uint64_le(void* buf); uint64_t get_uint64_le(void* buf);
unsigned long get_long_le(void* buf); uint32_t get_long_le(void* buf);
unsigned short get_short_le(void* buf); uint16_t get_short_le(void* buf);
unsigned long get_long_be(void* buf); uint32_t get_long_be(void* buf);
unsigned short get_short_be(void* buf); uint16_t get_short_be(void* buf);
long get_slong(void* buf); int32_t get_slong(void* buf);
unsigned long get_itunes_int32(char* value, int count); uint32_t get_itunes_int32(char* value, int count);
long parse_tag(const char* name, char* value, struct mp3entry* id3, long parse_tag(const char* name, char* value, struct mp3entry* id3,
char* buf, long buf_remaining, enum tagtype type); char* buf, long buf_remaining, enum tagtype type);