mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/2] libfile: advance offset in pread_full() on short reads
Date: Wed, 26 Aug 2026 11:55:37 +0200	[thread overview]
Message-ID: <20260826095604.2652204-1-a.fatoum@pengutronix.de> (raw)

pread_full() loops until the requested size was read, but reads from
the same offset on every iteration, so a short read is followed by
re-reading the same data instead of the remainder.

Advance the offset along with the buffer pointer.

Fixes: 59d6b83f1d4b ("libfile: implement new pread_full")
Assisted-by: Claude:fable-5
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
While a fix, I would keep it in next, just to watch if this leads to
adverse effects.
---
 lib/libfile.c    | 1 +
 scripts/common.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/lib/libfile.c b/lib/libfile.c
index cf78c70354d9..bd0118a7e5be 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -93,6 +93,7 @@ int pread_full(int fd, void *buf, size_t size, loff_t offset)
 			return now;
 		size -= now;
 		buf += now;
+		offset += now;
 	}
 
 	return insize - size;
diff --git a/scripts/common.c b/scripts/common.c
index a6eee968b79d..6615cfb38b55 100644
--- a/scripts/common.c
+++ b/scripts/common.c
@@ -210,6 +210,7 @@ int pread_full(int fd, void *buf, size_t size, loff_t offset)
 			return now;
 		size -= now;
 		buf += now;
+		offset += now;
 	}
 
 	return insize - size;
-- 
2.47.3




             reply	other threads:[~2026-08-26  9:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26  9:55 Ahmad Fatoum [this message]
2026-08-26  9:55 ` [PATCH 2/2] libfile: allow fixup_path_case() to resolve directories Ahmad Fatoum
2026-08-28 12:18 ` [PATCH 1/2] libfile: advance offset in pread_full() on short reads Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260826095604.2652204-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox