diff options
author | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-05-17 13:57:07 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-05-18 15:27:33 +1000 |
commit | 63796c9e89dee9f04bdc2c2c03fb5032c26ba827 (patch) | |
tree | 2a7d6d0c6d8a05b0f8a8d1b48e56468a3e2a57ce /libflash | |
parent | 2b2047fbf4630574058398c86d683f7696dbeb4e (diff) | |
download | skiboot-63796c9e89dee9f04bdc2c2c03fb5032c26ba827.zip skiboot-63796c9e89dee9f04bdc2c2c03fb5032c26ba827.tar.gz skiboot-63796c9e89dee9f04bdc2c2c03fb5032c26ba827.tar.bz2 |
libflash: fix bug on reading truncated flash file
If we had a truncated file where libflash would attempt to read past
the end, instead of erroring out, we'd get stuck in an infinite loop.
Why? Because we weren't acknowledging that read() returns 0 on EOF.
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com>
Diffstat (limited to 'libflash')
-rw-r--r-- | libflash/file.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libflash/file.c b/libflash/file.c index 72e2da9..478bc13 100644 --- a/libflash/file.c +++ b/libflash/file.c @@ -72,7 +72,7 @@ static int file_read(struct blocklevel_device *bl, uint32_t pos, void *buf, uint while (count < len) { rc = read(file_data->fd, buf, len); /* errno should remain set */ - if (rc == -1) + if (rc == -1 || rc == 0) return FLASH_ERR_BAD_READ; count += rc; |