Message ID | 20240617072905.2275940-3-dominique.martinet@atmark-techno.com |
---|---|
State | Accepted |
Headers | show |
Series | misc fixes from chunked stream rework | expand |
Hi Dominique, On 17.06.24 09:29, Dominique Martinet wrote: > fill_buffer would return 0 after having filled buffer/updated checksums > if it reaches the end of file (returns 0) after another read. > > In practice, this never happens because the caller knows how much to > read, and chunks are smaller than what had been previously written in > the pipe so this is a theorical problem, Yes, if it happens, there some bug somewhere else because the caller passes the size. Anyway, it is not bad to fix it. > but because the checksums are > correctly updated until the end this would not be detected if it happens > in practice (the end of the data would just not be fed to the handler), > so this is best fixed. > > Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> > --- > core/cpio_utils.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/core/cpio_utils.c b/core/cpio_utils.c > index 00b15f030c74..6178fedca216 100644 > --- a/core/cpio_utils.c > +++ b/core/cpio_utils.c > @@ -73,7 +73,7 @@ static int _fill_buffer(int fd, unsigned char *buf, unsigned int nbytes, unsigne > return -EFAULT; > } > if (len == 0) { > - return 0; > + return count; > } > if (checksum) > for (i = 0; i < len; i++) Acked-by: Stefano Babic <stefano.babic@swupdate.org>
diff --git a/core/cpio_utils.c b/core/cpio_utils.c index 00b15f030c74..6178fedca216 100644 --- a/core/cpio_utils.c +++ b/core/cpio_utils.c @@ -73,7 +73,7 @@ static int _fill_buffer(int fd, unsigned char *buf, unsigned int nbytes, unsigne return -EFAULT; } if (len == 0) { - return 0; + return count; } if (checksum) for (i = 0; i < len; i++)
fill_buffer would return 0 after having filled buffer/updated checksums if it reaches the end of file (returns 0) after another read. In practice, this never happens because the caller knows how much to read, and chunks are smaller than what had been previously written in the pipe so this is a theorical problem, but because the checksums are correctly updated until the end this would not be detected if it happens in practice (the end of the data would just not be fed to the handler), so this is best fixed. Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> --- core/cpio_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)