summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-10-24 13:00:32 +0200
committerPeter Wu <lekensteyn@gmail.com>2013-10-24 13:00:32 +0200
commit93eade5fc5346b11805fa13db6147409d4932b03 (patch)
tree7c2b329a2687a17bf484ed46b518a3e0554654da
parent5105f55149abd5ccd384e149f4de0c27ad4c1c8d (diff)
downloadc-files-93eade5fc5346b11805fa13db6147409d4932b03.tar.gz
slice: allow zero-length size
-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;