From 849e8abe8dbf624a58542e5ee0091a242cdf9c3a Mon Sep 17 00:00:00 2001 From: Roman Artiukhin Date: Fri, 28 Mar 2025 13:35:06 +0200 Subject: [PATCH] metadata: opus, vorbis, speex: Fix 0 is supplied as base64 char when parsing album art metadata For some reason it caused a crash on asan enabled simulator builds but worked fine otherwise. Fixup for 0847bcc1 and ac8714dd Change-Id: Iff1c2779d5fa6889c743cdccd8e1feaf55684394 --- lib/rbcodec/metadata/vorbis.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/rbcodec/metadata/vorbis.c b/lib/rbcodec/metadata/vorbis.c index 31235dbae3..3addc57ef7 100644 --- a/lib/rbcodec/metadata/vorbis.c +++ b/lib/rbcodec/metadata/vorbis.c @@ -326,14 +326,14 @@ size_t base64_decode(const char *in, size_t in_len, unsigned char *out) } break; } - int index = in[i] - B64_START_CHAR; - if (index < 0 || index >= (int)ARRAYLEN(b64_codes)) +#ifdef SIMULATOR + if (index < 0 || index >= (int)ARRAYLEN(b64_codes) || b64_codes[index] < 0) { - out[len] = '\0'; + DEBUGF("Invalid base64 char: '%c', char code: %i.\n", in[i], in[i]); break; } - +#endif val = (val << 6) | b64_codes[index]; if ((++i & 3) == 0) @@ -429,7 +429,7 @@ long read_vorbis_tags(int fd, struct mp3entry *id3, int after_block_pos = lseek(fd, 0, SEEK_CUR); char* buf = id3->path; - size_t outlen = base64_decode(buf, MIN(read_len, (int32_t) sizeof(id3->path)), buf); + size_t outlen = base64_decode(buf, MIN(read_len, (int32_t) sizeof(id3->path) - 1), buf); int picframe_pos; parse_flac_album_art(buf, outlen, &id3->albumart.type, &picframe_pos);