From bfef6139195d8fce106f02cef7a5a283394d4c31 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 2 Jun 2025 22:08:10 +0200 Subject: [PATCH] wma: Use unsigned byte arrays. They get initialized with values which cause an overflow on systems where char is signed. --- wma.h | 2 +- wma_afh.c | 10 +++++----- wma_common.c | 10 ++++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/wma.h b/wma.h index b260feb9..530448ef 100644 --- a/wma.h +++ b/wma.h @@ -34,7 +34,7 @@ struct asf_header_info { /* wma_common.c */ __a_const int wma_log2(unsigned int v); -const char *search_pattern(const char *pattern, int pattern_len, +const char *search_pattern(const uint8_t *pattern, int pattern_len, const char *buf, int buf_size); int read_asf_header(const char *buf, int loaded, struct asf_header_info *ahi); diff --git a/wma_afh.c b/wma_afh.c index 97f0df47..f262706d 100644 --- a/wma_afh.c +++ b/wma_afh.c @@ -96,22 +96,22 @@ static char *get_str16(const char *in, int len) return out; } -static const char content_description_header[] = { +static const uint8_t content_description_header[] = { 0x33, 0x26, 0xb2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }; -static const char extended_content_header[] = { +static const uint8_t extended_content_header[] = { 0x40, 0xA4, 0xD0, 0xD2, 0x07, 0xE3, 0xD2, 0x11, 0x97, 0xF0, 0x00, 0xA0, 0xC9, 0x5E, 0xA8, 0x50 }; -static const char year_tag_header[] = { /* WM/Year */ +static const uint8_t year_tag_header[] = { /* WM/Year */ 0x57, 0x00, 0x4d, 0x00, 0x2f, 0x00, 0x59, 0x00, 0x65, 0x00, 0x61, 0x00, 0x72, 0x00 }; -static const char album_tag_header[] = { /* WM/AlbumTitle */ +static const uint8_t album_tag_header[] = { /* WM/AlbumTitle */ 0x57, 0x00, 0x4d, 0x00, 0x2f, 0x00, 0x41, 0x00, 0x6c, 0x00, 0x62, 0x00, 0x75, 0x00, 0x6d, 0x00, 0x54, 0x00, 0x69, 0x00, 0x74, 0x00, 0x6c, 0x00, @@ -304,7 +304,7 @@ static int read_asf_objects(const char *src, size_t size, uint32_t num_objects, return 1; } -static const char top_level_header_object_guid[] = { +static const uint8_t top_level_header_object_guid[] = { 0x30, 0x26, 0xb2, 0x75, 0x8e, 0x66, 0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }; diff --git a/wma_common.c b/wma_common.c index b123b5d2..0c8c8835 100644 --- a/wma_common.c +++ b/wma_common.c @@ -21,7 +21,7 @@ * * \return A pointer into \a buf or \p NULL if the pattern was not found. */ -const char *search_pattern(const char *pattern, int pattern_len, +const char *search_pattern(const uint8_t *pattern, int pattern_len, const char *buf, int buf_size) { const char *p, *end = buf + buf_size; @@ -40,7 +40,7 @@ const char *search_pattern(const char *pattern, int pattern_len, static int find_file_properties(const char *buf, int len) { - const char pattern[] = {0xa1, 0xdc, 0xab, 0x8c}; + const uint8_t pattern[] = {0xa1, 0xdc, 0xab, 0x8c}; const char *p = search_pattern(pattern, sizeof(pattern), buf, len); if (!p) @@ -49,12 +49,10 @@ static int find_file_properties(const char *buf, int len) return p - buf + 16; } -/* - 40 9e 69 f8 4d 5b cf 11 a8 fd 00 80 5f 5c 44 2b - */ +/* 40 9e 69 f8 4d 5b cf 11 a8 fd 00 80 5f 5c 44 2b */ static int find_audio_stream_info(const char *buf, int len) { - const char pattern[] = {0x40, 0x9e, 0x69, 0xf8}; + const uint8_t pattern[] = {0x40, 0x9e, 0x69, 0xf8}; const char *p = search_pattern(pattern, sizeof(pattern), buf, len); if (!p) -- 2.39.5