diff options
author | Sami Tolvanen <samitolvanen@google.com> | 2018-08-02 11:13:15 -0700 |
---|---|---|
committer | Sami Tolvanen <samitolvanen@google.com> | 2018-08-03 08:12:25 -0700 |
commit | 9798825a05a606b2d77fe9e918fda1e5ec981b62 (patch) | |
tree | a742939d2c6bcb88893991990cce753062899e51 /libfec | |
parent | 1b184b4451cc991893dbbf16c1f610329448c0ff (diff) | |
download | extras-9798825a05a606b2d77fe9e918fda1e5ec981b62.tar.gz |
libfec: fix a check for read-only mode
O_RDONLY is defined as zero, which makes the test for it incorrect. As
we don't allow O_WRONLY when opening files, it's sufficient to test for
O_RDWR instead.
Bug: 112147169
Test: tested that corrupt zero blocks are not read without O_RDWR
Change-Id: I2328cda4285f4c9daf98dffa2a6602c9db5ad539
Diffstat (limited to 'libfec')
-rw-r--r-- | libfec/fec_read.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libfec/fec_read.cpp b/libfec/fec_read.cpp index 0f5ec998..ec2750e7 100644 --- a/libfec/fec_read.cpp +++ b/libfec/fec_read.cpp @@ -319,7 +319,7 @@ static ssize_t verity_read(fec_handle *f, uint8_t *dest, size_t count, /* if we are in read-only mode and expect to read a zero block, skip reading and just return zeros */ - if (f->mode & O_RDONLY && expect_zeros) { + if ((f->mode & O_ACCMODE) == O_RDONLY && expect_zeros) { memset(data, 0, FEC_BLOCKSIZE); goto valid; } |