summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slice.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/slice.c b/slice.c
index 119ecef..005084d 100644
--- a/slice.c
+++ b/slice.c
@@ -34,7 +34,7 @@ int main(int argc, char **argv) {
bytes_end += seekpos;
}
- if (bytes_end <= seekpos) {
+ if (bytes_end < seekpos) {
fprintf(stderr, "The last byte must be greater than the first byte.\n");
return 1;
}
@@ -60,6 +60,7 @@ int main(int argc, char **argv) {
if (bytes_end - read_bytes < read_count)
read_count = bytes_end - read_bytes;
+ /* if fseek failed, discard some bytes */
if (read_bytes < seekpos)
skip_bytes = seekpos - read_bytes;