mirror of
https://github.com/ipxe/ipxe
synced 2026-01-23 04:29:01 +03:00
[deflate] Remove userptr_t from decompression code
Simplify the deflate, zlib, and gzip decompression code by assuming that all content is fully accessible via pointer dereferences. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -11,7 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <ipxe/uaccess.h>
|
||||
|
||||
/** Compression formats */
|
||||
enum deflate_format {
|
||||
@@ -163,6 +162,11 @@ struct deflate {
|
||||
/** Format */
|
||||
enum deflate_format format;
|
||||
|
||||
/** Current input data pointer */
|
||||
const uint8_t *in;
|
||||
/** End of input data pointer */
|
||||
const uint8_t *end;
|
||||
|
||||
/** Accumulator */
|
||||
uint32_t accumulator;
|
||||
/** Bit-reversed accumulator
|
||||
@@ -240,7 +244,7 @@ struct deflate {
|
||||
/** A chunk of data */
|
||||
struct deflate_chunk {
|
||||
/** Data */
|
||||
userptr_t data;
|
||||
void *data;
|
||||
/** Current offset */
|
||||
size_t offset;
|
||||
/** Length of data */
|
||||
@@ -256,7 +260,7 @@ struct deflate_chunk {
|
||||
* @v len Length
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
deflate_chunk_init ( struct deflate_chunk *chunk, userptr_t data,
|
||||
deflate_chunk_init ( struct deflate_chunk *chunk, void *data,
|
||||
size_t offset, size_t len ) {
|
||||
|
||||
chunk->data = data;
|
||||
@@ -277,7 +281,7 @@ static inline int deflate_finished ( struct deflate *deflate ) {
|
||||
extern void deflate_init ( struct deflate *deflate,
|
||||
enum deflate_format format );
|
||||
extern int deflate_inflate ( struct deflate *deflate,
|
||||
struct deflate_chunk *in,
|
||||
const void *data, size_t len,
|
||||
struct deflate_chunk *out );
|
||||
|
||||
#endif /* _IPXE_DEFLATE_H */
|
||||
|
||||
@@ -28,15 +28,15 @@ union zlib_magic {
|
||||
* @v magic Magic header
|
||||
* @ret is_valid Magic header is valid
|
||||
*/
|
||||
static inline int zlib_magic_is_valid ( union zlib_magic *magic ) {
|
||||
static inline int zlib_magic_is_valid ( const union zlib_magic *magic ) {
|
||||
|
||||
/* Check magic value as per RFC 6713 */
|
||||
return ( ( ( magic->cmf & 0x8f ) == 0x08 ) &&
|
||||
( ( be16_to_cpu ( magic->check ) % 31 ) == 0 ) );
|
||||
}
|
||||
|
||||
extern int zlib_deflate ( enum deflate_format format, struct deflate_chunk *in,
|
||||
struct image *extracted );
|
||||
extern int zlib_deflate ( enum deflate_format format, const void *data,
|
||||
size_t len, struct image *extracted );
|
||||
|
||||
extern struct image_type zlib_image_type __image_type ( PROBE_NORMAL );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user