From: Andre Noll Date: Wed, 18 Aug 2021 14:44:15 +0000 (+0200) Subject: aac_afh: Be more lenient about zero sized reads. X-Git-Tag: v0.7.1~36 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=cc2649458c2b732128cb2f10ab1c595ef9853349 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. --- 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);