Message ID | b404fdf066e802328bcbcefeb9da7c996738f840.1702047081.git.ps@pks.im (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | reftable: small set of fixes | expand |
On Fri, Dec 08, 2023 at 03:53:02PM +0100, Patrick Steinhardt wrote: > There are calls to pread(3P) and read(3P) where we don't properly handle > interrupts. Convert them to use `pread_in_full()` and `read_in_full()`, Just checking... do you mean "interrupt" in the kernel sense? Or are you referring to the possibility of short reads/writes (in later patches)? Thanks, Taylor
On Fri, Dec 08, 2023 at 04:30:02PM -0500, Taylor Blau wrote: > On Fri, Dec 08, 2023 at 03:53:02PM +0100, Patrick Steinhardt wrote: > > There are calls to pread(3P) and read(3P) where we don't properly handle > > interrupts. Convert them to use `pread_in_full()` and `read_in_full()`, > > Just checking... do you mean "interrupt" in the kernel sense? Or are you > referring to the possibility of short reads/writes (in later patches)? Both. The callsites I'm converting are explicitly checking that they get the exact number of requested bytes. That means that we'll have to loop both around EINTR/EAGAIN, but also around short reads. Patrick
diff --git a/reftable/blocksource.c b/reftable/blocksource.c index 8331b34e82..a1ea304429 100644 --- a/reftable/blocksource.c +++ b/reftable/blocksource.c @@ -109,7 +109,7 @@ static int file_read_block(void *v, struct reftable_block *dest, uint64_t off, struct file_block_source *b = v; assert(off + size <= b->size); dest->data = reftable_malloc(size); - if (pread(b->fd, dest->data, size, off) != size) + if (pread_in_full(b->fd, dest->data, size, off) != size) return -1; dest->len = size; return size; diff --git a/reftable/stack.c b/reftable/stack.c index ddbdf1b9c8..ed108a929b 100644 --- a/reftable/stack.c +++ b/reftable/stack.c @@ -92,7 +92,7 @@ static int fd_read_lines(int fd, char ***namesp) } buf = reftable_malloc(size + 1); - if (read(fd, buf, size) != size) { + if (read_in_full(fd, buf, size) != size) { err = REFTABLE_IO_ERROR; goto done; }
There are calls to pread(3P) and read(3P) where we don't properly handle interrupts. Convert them to use `pread_in_full()` and `read_in_full()`, respectively. Signed-off-by: Patrick Steinhardt <ps@pks.im> --- reftable/blocksource.c | 2 +- reftable/stack.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)