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
This commit is contained in:
Roman Artiukhin 2025-03-28 13:35:06 +02:00 committed by Solomon Peachy
parent b6f8f31b7c
commit 849e8abe8d

View file

@ -326,14 +326,14 @@ size_t base64_decode(const char *in, size_t in_len, unsigned char *out)
} }
break; break;
} }
int index = in[i] - B64_START_CHAR; 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; break;
} }
#endif
val = (val << 6) | b64_codes[index]; val = (val << 6) | b64_codes[index];
if ((++i & 3) == 0) 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); int after_block_pos = lseek(fd, 0, SEEK_CUR);
char* buf = id3->path; 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; int picframe_pos;
parse_flac_album_art(buf, outlen, &id3->albumart.type, &picframe_pos); parse_flac_album_art(buf, outlen, &id3->albumart.type, &picframe_pos);