Chromium Code Reviews| Index: native_client_sdk/src/libraries/nacl_io/kernel_handle.cc |
| diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc b/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc |
| index 1eaa88e0b7669d895c134fdc7b90b5a396ac09ec..5736a3ac875b0c753ec23a68561bd6aa632a5e89 100644 |
| --- a/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc |
| +++ b/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc |
| @@ -55,7 +55,7 @@ Error KernelHandle::Init(int open_flags) { |
| Error KernelHandle::Seek(off_t offset, int whence, off_t* out_offset) { |
| // By default, don't move the offset. |
| *out_offset = offset; |
| - size_t base; |
| + ssize_t base; |
| size_t node_size; |
| AUTO_LOCK(handle_lock_); |
| @@ -64,8 +64,6 @@ Error KernelHandle::Seek(off_t offset, int whence, off_t* out_offset) { |
| return error; |
| switch (whence) { |
| - default: |
| - return -1; |
| case SEEK_SET: |
| base = 0; |
| break; |
| @@ -75,12 +73,14 @@ Error KernelHandle::Seek(off_t offset, int whence, off_t* out_offset) { |
| case SEEK_END: |
| base = node_size; |
| break; |
| + default: |
| + return -1; |
| } |
| if (base + offset < 0) |
|
Sam Clegg
2013/11/15 03:11:55
This was always failing because base was is unsign
binji
2013/11/15 17:26:23
scary, nice catch.
|
| return EINVAL; |
| - off_t new_offset = base + offset; |
| + size_t new_offset = base + offset; |
| // Seeking past the end of the file will zero out the space between the old |
| // end and the new end. |