Drop trailing garbage of gzip decompress

I previously refered to minigzip from libz which copies all trailing
data to the output when decompressing. However, gzip, on the other
hand, drop trailing garbage by default. Consider ZIMAGE append
the kernel size with zero padding, we should drop trailing garbage
as well.
This commit is contained in:
LoveSy 2023-03-14 10:12:23 +08:00 committed by John Wu
parent 3cc81bb3fd
commit 98813c24fb

View File

@ -86,7 +86,7 @@ private:
inflate(&strm, flush); inflate(&strm, flush);
} else { } else {
mode = COPY; mode = COPY;
bwrite(b, 1); return true;
} }
} }
strm.next_in = (Bytef *) buf; strm.next_in = (Bytef *) buf;
@ -103,7 +103,7 @@ private:
code = deflate(&strm, flush); code = deflate(&strm, flush);
break; break;
case COPY: case COPY:
return bwrite(buf, len); return true;
default: default:
// should have been handled // should have been handled
return false; return false;
@ -137,7 +137,7 @@ private:
} }
// There is still data in the stream, we need to copy it // There is still data in the stream, we need to copy it
mode = COPY; mode = COPY;
bwrite(strm.next_in, strm.avail_in); return true;
} }
} while (strm.avail_out == 0); } while (strm.avail_out == 0);
return true; return true;