From: Ralph Ronnquist Date: Wed, 10 Aug 2022 15:39:54 +0000 (+1000) Subject: fixup of ocerlay_merge X-Git-Tag: 0.5.2~4 X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=6c93ae8d4f1955020adedfa67a43478dba854ab0;p=rrq%2Ffusefile.git fixup of ocerlay_merge --- diff --git a/fusefile.c b/fusefile.c index f74632a..30ec7fa 100644 --- a/fusefile.c +++ b/fusefile.c @@ -416,14 +416,17 @@ static int overlay_merge(char *buf,off_t off,size_t size) { p = 0; } for ( ; p < overlay.count && BEG(p) < off+size; p++ ) { + if ( END(p) < off ) { + continue; + } size_t delta = FRAG(p)->size; - if ( BEG(p) > off ) { + if ( BEG(p) < off ) { + delta -= off - BEG(p); + } else { size_t skip = BEG(p) - off; off += skip; size -= skip; buf += skip; - } else { - delta = off - BEG(p); } if ( delta > size ) { delta = size;