From cc2649458c2b732128cb2f10ab1c595ef9853349 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 18 Aug 2021 16:44:15 +0200 Subject: [PATCH] aac_afh: Be more lenient about zero sized reads. These actually happen for example when the file contains a meta tag with an empty string value. POSIX says that the read() function shall return zero and have no other results, so don't return -1 if the number of bytes read is zero. Similarly, return zero if the file offset is beyond EOF. --- aac_afh.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/aac_afh.c b/aac_afh.c index 2b3dd2cc..026df50f 100644 --- a/aac_afh.c +++ b/aac_afh.c @@ -37,12 +37,8 @@ static uint32_t aac_afh_read_cb(void *user_data, void *dest, uint32_t want) struct aac_afh_context *c = user_data; uint32_t have, rv; - if (want == 0 || c->fpos >= c->mapsize) { - PARA_INFO_LOG("failed attempt to read %u bytes @%zu\n", want, - c->fpos); - errno = EAGAIN; - return -1; - } + if (want == 0 || c->fpos >= c->mapsize) + return 0; have = c->mapsize - c->fpos; rv = PARA_MIN(have, want); PARA_DEBUG_LOG("reading %u bytes @%zu\n", rv, c->fpos); -- 2.39.5