aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2026-07-10 04:04:40 +0000
committerWarner Losh <imp@FreeBSD.org>2026-07-10 04:09:41 +0000
commit1d1298269d4c6e3ce41db6265f32ff6c2faecaf7 (patch)
tree9f32443e69d670e97c884e27065f5f9f03e49cf4
parent603270b4d69ecf0a8405e34bd41838873ddad72d (diff)
loader.efi: Simplify the code for null decompression a little
This code is simpler when we spell it the Unix way. Also, add sanity checks to make sure the offset is where we think it is. Fixes: afee781523e4 ("loader.efi: Recognize new memdisk=<url> and memcd=<url> options") Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D58070
-rw-r--r--stand/efi/loader/decompress.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/stand/efi/loader/decompress.c b/stand/efi/loader/decompress.c
index 1e18618db6f2..5c16f7d9bb2a 100644
--- a/stand/efi/loader/decompress.c
+++ b/stand/efi/loader/decompress.c
@@ -335,10 +335,14 @@ null_step(decomp_state *dctx, uint8_t *buf, size_t len, size_t offset)
printf("Too much data recieved!");
return (err);
}
+ if ((uintptr_t)dctx->buf_cur - (uintptr_t)dctx->buf != offset) {
+ printf("OH NO! The offset is %llu but I expected %llu\n", ULL(offset),
+ ULL((uintptr_t)dctx->buf_cur - (uintptr_t)dctx->buf));
+ return (err);
+ }
- CHAR8 *src = buf;
- CHAR8 *dst = (void*)(uintptr_t)(dctx->buf + offset);
- BS->CopyMem(dst, src, len);
+ memcpy(dctx->buf_cur, buf, len);
+ dctx->buf_cur += len;
return (end == dctx->size ? done : ok);
}