From f789c0fb00c27b331cb6ffc6a4f19ddc15c9d1a8 Mon Sep 17 00:00:00 2001 From: Sean Bartell Date: Mon, 20 Jun 2011 02:35:05 -0400 Subject: [PATCH] Fix yet another 64-bit bug. 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. --- apps/metadata/metadata_common.c | 10 +++++----- apps/metadata/metadata_common.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/metadata/metadata_common.c b/apps/metadata/metadata_common.c index 6c420d9..e620514 100644 --- a/apps/metadata/metadata_common.c +++ b/apps/metadata/metadata_common.c @@ -155,7 +155,7 @@ uint64_t get_uint64_le(void* buf) } /* 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; @@ -163,7 +163,7 @@ unsigned long get_long_le(void* buf) } /* 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; @@ -171,7 +171,7 @@ unsigned short get_short_le(void* buf) } /* 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; @@ -179,14 +179,14 @@ unsigned long get_long_be(void* buf) } /* 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; 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"; const char* c; diff --git a/apps/metadata/metadata_common.h b/apps/metadata/metadata_common.h index b2c76af..891ed68 100644 --- a/apps/metadata/metadata_common.h +++ b/apps/metadata/metadata_common.h @@ -59,10 +59,10 @@ int read_uint64be(int fd, uint64_t* buf); #endif uint64_t get_uint64_le(void* buf); -unsigned long get_long_le(void* buf); -unsigned short get_short_le(void* buf); -unsigned long get_long_be(void* buf); -long get_slong(void* buf); -unsigned long get_itunes_int32(char* value, int count); +uint32_t get_long_le(void* buf); +uint16_t get_short_le(void* buf); +uint32_t get_long_be(void* buf); +int32_t get_slong(void* buf); +uint32_t get_itunes_int32(char* value, int count); long parse_tag(const char* name, char* value, struct mp3entry* id3, char* buf, long buf_remaining, enum tagtype type); -- 1.7.5.2