diff options
Diffstat (limited to 'lib/rbcodec/codecs')
-rw-r--r-- | lib/rbcodec/codecs/opus.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/rbcodec/codecs/opus.c b/lib/rbcodec/codecs/opus.c index acae1aaacc..f0ad5e8ba4 100644 --- a/lib/rbcodec/codecs/opus.c +++ b/lib/rbcodec/codecs/opus.c | |||
@@ -72,7 +72,8 @@ static int seek_ogg_page(uint64_t filepos) | |||
72 | ci->seek_buffer(ci->curpos - sizeof(buf)); | 72 | ci->seek_buffer(ci->curpos - sizeof(buf)); |
73 | LOGF("next page %ld", ci->curpos); | 73 | LOGF("next page %ld", ci->curpos); |
74 | return 1; | 74 | return 1; |
75 | } | 75 | } else |
76 | ci->seek_buffer(ci->curpos - (sizeof(buf) - 1)); | ||
76 | } | 77 | } |
77 | } | 78 | } |
78 | return 0; | 79 | return 0; |
@@ -81,20 +82,19 @@ static int seek_ogg_page(uint64_t filepos) | |||
81 | /* seek to comment header */ | 82 | /* seek to comment header */ |
82 | static int seek_opus_tags(void) | 83 | static int seek_opus_tags(void) |
83 | { | 84 | { |
84 | int pos = 0; | ||
85 | const int64_t maxpos = sizeof(OpusHeader) + 1024; | ||
86 | const char synccode[] = "OpusTags"; | 85 | const char synccode[] = "OpusTags"; |
87 | char buf[sizeof(synccode)]; | 86 | char buf[sizeof(synccode) - 1]; /* Exclude null */ |
88 | ci->seek_buffer(0); | 87 | ci->seek_buffer(0); |
89 | while (ci->read_filebuf(buf, 1) == 1 && ci->curpos < maxpos) { | 88 | while (ci->read_filebuf(buf, 1) == 1) { |
90 | if (buf[0] == synccode[0]) { | 89 | if (buf[0] == synccode[0]) { |
91 | if (ci->read_filebuf(&buf[1], sizeof(buf) - 2) != sizeof(buf) - 2) | 90 | if (ci->read_filebuf(&buf[1], sizeof(buf) - 1) != sizeof(buf) - 1) |
92 | break; | 91 | break; |
93 | if (memcmp(buf, synccode, sizeof(buf)) == 0) { | 92 | if (memcmp(buf, synccode, sizeof(buf)) == 0) { |
94 | ci->seek_buffer(ci->curpos - sizeof(buf)); | 93 | ci->seek_buffer(ci->curpos - sizeof(buf)); |
95 | LOGF("OpusTags %ld", ci->curpos); | 94 | LOGF("OpusTags %ld", ci->curpos); |
96 | return 1; | 95 | return 1; |
97 | } | 96 | } else |
97 | ci->seek_buffer(ci->curpos - (sizeof(buf) - 1)); | ||
98 | } | 98 | } |
99 | } | 99 | } |
100 | /* comment header not found probably invalid file */ | 100 | /* comment header not found probably invalid file */ |