diff options
author | Peter Wu <lekensteyn@gmail.com> | 2013-10-24 13:00:32 +0200 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2013-10-24 13:00:32 +0200 |
commit | 93eade5fc5346b11805fa13db6147409d4932b03 (patch) | |
tree | 7c2b329a2687a17bf484ed46b518a3e0554654da | |
parent | 5105f55149abd5ccd384e149f4de0c27ad4c1c8d (diff) | |
download | c-files-93eade5fc5346b11805fa13db6147409d4932b03.tar.gz |
slice: allow zero-length size
-rw-r--r-- | slice.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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; |