Skip to content

Commit

Permalink
tools/fs-common.c: workaround error at end of file
Browse files Browse the repository at this point in the history
OpenBSD requests a chunk of data at the end of the file. Currently
sqsh_file_reader_advance() returns an error in this case. This
commit works around this behavior by returning early when
zero size is requested.
  • Loading branch information
Gottox committed Aug 20, 2023
1 parent 5289c86 commit d32ea29
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/fs-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d32ea29

Please sign in to comment.