From 82a64c65b1876da766fe7f7d418387868b111d09 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 24 Jan 2023 23:13:55 +0100 Subject: [PATCH] server: Don't save bogus chunk table for aac files. The audio file selector stores the chunk table of each audio file as an osl disk object. Since the aac audio format handler employs dynamic chunks, these on-disk chunk tables of aac files will never be consulted for streaming. They exist only for consistency with the other audio formats and should be empty. Due to a mis-computation of the chunk table size in the callback of the add command we happen to store the serialized lopsub parse result as the chunk table. This is a benign bug since it only affects the ls command, and only if -l=c is given to print the chunk table. --- aft.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aft.c b/aft.c index 6aeb0589..4fb60f91 100644 --- a/aft.c +++ b/aft.c @@ -1638,7 +1638,8 @@ static int com_add_callback(struct afs_callback_arg *aca) char asc[2 * HASH2_SIZE + 1]; int ret; char afsi_buf[AFSI_SIZE]; - char *slpr = buf + read_u32(buf + CAB_LPR_OFFSET); + uint32_t slpr_offset = read_u32(buf + CAB_LPR_OFFSET); + char *slpr = buf + slpr_offset; struct afs_info default_afsi = {.last_played = 0}; uint16_t afhi_offset, chunks_offset; const struct lls_command *cmd = SERVER_CMD_CMD_PTR(ADD); @@ -1706,6 +1707,7 @@ static int com_add_callback(struct afs_callback_arg *aca) /* no hs or force mode, child must have sent afhi */ afhi_offset = read_u32(buf + CAB_AFHI_OFFSET_POS); chunks_offset = read_u32(buf + CAB_CHUNKS_OFFSET_POS); + assert(chunks_offset <= slpr_offset); objs[AFTCOL_AFHI].data = buf + afhi_offset; objs[AFTCOL_AFHI].size = chunks_offset - afhi_offset; @@ -1713,7 +1715,7 @@ static int com_add_callback(struct afs_callback_arg *aca) if (!objs[AFTCOL_AFHI].size) /* "impossible" */ goto out; objs[AFTCOL_CHUNKS].data = buf + chunks_offset; - objs[AFTCOL_CHUNKS].size = aca->query.size - chunks_offset; + objs[AFTCOL_CHUNKS].size = slpr_offset - chunks_offset; if (pb && !hs) { /* update pb's hash */ char old_asc[2 * HASH2_SIZE + 1]; unsigned char *old_hash; -- 2.39.5