fixup of ocerlay_merge
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Wed, 10 Aug 2022 15:39:54 +0000 (01:39 +1000)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Wed, 10 Aug 2022 15:39:54 +0000 (01:39 +1000)
fusefile.c

index f74632a5356b0040f58b4118083bca91a5b9cbc6..30ec7fa284c7ce1f330daaede1de2fb1835ee9b5 100644 (file)
@@ -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;