mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
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: afee781523 ("loader.efi: Recognize new memdisk=<url> and memcd=<url> options")
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D58068
This commit is contained in:
1 parent
f273414c11
commit
a22fa5ec74
1 file changed
+7
-3
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user