From 90c6d1942002296fa43e5aa3736637819e01a022 Mon Sep 17 00:00:00 2001 From: Sean Bartell Date: Mon, 20 Jun 2011 02:35:05 -0400 Subject: [PATCH 1/4] Fix yet another 64-bit bug. (uploaded) 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 | 12 ++++++------ apps/metadata/metadata_common.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/metadata/metadata_common.c b/apps/metadata/metadata_common.c index 1ad89d1..7811237 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,7 +179,7 @@ unsigned long get_long_be(void* buf) } /* 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; @@ -187,14 +187,14 @@ unsigned short get_short_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 a48c2a4..db91729 100644 --- a/apps/metadata/metadata_common.h +++ b/apps/metadata/metadata_common.h @@ -59,11 +59,11 @@ 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); -unsigned short get_short_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); +uint16_t get_short_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.6