diff --git a/tools/fs-common.c b/tools/fs-common.c index 5e27fb454..01d3f570f 100644 --- a/tools/fs-common.c +++ b/tools/fs-common.c @@ -145,6 +145,15 @@ fs_common_read( size = file_size - offset; } + + // This works around a bug in sqsh_file_reader_advance: + // Reading a 0 size at the end of the file will return + // SQSH_ERROR_OUT_OF_BOUNDS. This should succeed instead, + // providing an empty buffer. + if (size == 0) { + return 0; + } + rv = sqsh_file_reader_advance(*reader, offset, size); if (rv < 0) { goto out;