git: a22fa5ec74e0 - main - laoder.efi: Fix error in download protcol
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 10 Jul 2026 04:18:41 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=a22fa5ec74e084c5786745e56939e78f7159007b
commit a22fa5ec74e084c5786745e56939e78f7159007b
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2026-07-10 04:04:20 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-07-10 04:09:41 +0000
laoder.efi: Fix error in download protcol
The download protocol calls download_data with FileOffset and
BufferLength of 0 first to start the download (no data yet
available). Calls it again with BufferLength == 0 and FileOffset the
size of the download (again, no data). It then starts calling with
BufferLength != 0 and FileOffset == 0 to start the download. The
heuristic I used to detect the start was wrong, so we'd allocate the
buffer twice. Fix that by being more explicit and not using the
heuristic that was bogus.
Fixes: afee781523e4 ("loader.efi: Recognize new memdisk=<url> and memcd=<url> options")
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D58068
---
stand/efi/loader/memdisk.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/stand/efi/loader/memdisk.c b/stand/efi/loader/memdisk.c
index 8d34d3ceae42..aa843916c799 100644
--- a/stand/efi/loader/memdisk.c
+++ b/stand/efi/loader/memdisk.c
@@ -50,11 +50,15 @@ download_data(IN VOID *Context, IN VOID *Buffer, IN UINTN BufferLength, IN UINTN
dl_state *ctx = Context;
decomp_state *dctx = ctx->dctx;
+ if (FileOffset == 0 && BufferLength == 0) {
+ printf("Staritng the download\n");
+ return (EFI_SUCCESS);
+ }
+
/*
- * Make a note of the size when we're hinted about it. But once
- * we start the download, ignore the hints.
+ * Make a note of the size when we're hinted about it.
*/
- if (ctx->size == 0 && BufferLength == 0) {
+ if (BufferLength == 0) {
printf("We know we will download %llu bytes\n", ULL(FileOffset));
ctx->size = FileOffset;
ctx->status = EFI_SUCCESS;