]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
wma: Use unsigned byte arrays.
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 2 Jun 2025 20:08:10 +0000 (22:08 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 12 Jun 2025 23:10:41 +0000 (01:10 +0200)
They get initialized with values which cause an overflow on systems where
char is signed.

wma.h
wma_afh.c
wma_common.c

diff --git a/wma.h b/wma.h
index b260feb99d76ea58511696cd0c04ddb4ec01b26c..530448ef2a6273ef5779981fed79f9837ee8932a 100644 (file)
--- 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);
 
index 97f0df4796fd9eec81b2cf01884ec38b51153836..f262706d4fa5240ebdc47aecdb9cbbee3352a176 100644 (file)
--- 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
 };
index b123b5d2104a24500b8123f94bc7e2c6b8622fbc..0c8c88354dd28e96c347c2c2a354030c134a8c95 100644 (file)
@@ -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)