diff options
| author | Michael Brown | 2025-04-30 15:14:51 +0200 |
|---|---|---|
| committer | Michael Brown | 2025-04-30 16:38:15 +0200 |
| commit | 05ad7833c51c942a5cb91540a054852bb991333b (patch) | |
| tree | ce84699ba21615ae75f3d4d5619dfac63d293e1f /src/image/zlib.c | |
| parent | [image] Add the concept of a static image (diff) | |
| download | ipxe-05ad7833c51c942a5cb91540a054852bb991333b.tar.gz ipxe-05ad7833c51c942a5cb91540a054852bb991333b.tar.xz ipxe-05ad7833c51c942a5cb91540a054852bb991333b.zip | |
[image] Make image data read-only to most consumers
Almost all image consumers do not need to modify the content of the
image. Now that the image data is a pointer type (rather than the
opaque userptr_t type), we can rely on the compiler to enforce this at
build time.
Change the .data field to be a const pointer, so that the compiler can
verify that image consumers do not modify the image content. Provide
a transparent .rwdata field for consumers who have a legitimate (and
now explicit) reason to modify the image content.
We do not attempt to impose any runtime restriction on checking
whether or not an image is writable. The only existing instances of
genuinely read-only images are the various unit test images, and it is
acceptable for defective test cases to result in a segfault rather
than a runtime error.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/image/zlib.c')
| -rw-r--r-- | src/image/zlib.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/image/zlib.c b/src/image/zlib.c index d7deee88b..23eb50e7d 100644 --- a/src/image/zlib.c +++ b/src/image/zlib.c @@ -65,7 +65,8 @@ int zlib_deflate ( enum deflate_format format, const void *data, size_t len, deflate_init ( deflate, format ); /* Initialise output chunk */ - deflate_chunk_init ( &out, extracted->data, 0, extracted->len ); + deflate_chunk_init ( &out, extracted->rwdata, 0, + extracted->len ); /* Decompress data */ if ( ( rc = deflate_inflate ( deflate, data, len, |
