Abstract xc_dom_check_gzip()'s reading of the uncompressed size into a
helper re-usable, in particular, by other decompressor code.
Sadly in the mini-os case this conflicts with other functions of the
same name (and purpose), which can't be easily replaced individually.
Yet it was requested that no full set of helpers be introduced at this
point in the release cycle. Hence the awkward XG_NEED_UNALIGNED.
Requested-by: Ian Jackson <iwj@xenproject.org>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
#include <zlib.h>
#include <assert.h>
+#define XG_NEED_UNALIGNED
#include "xg_private.h"
#include "_paths.h"
size_t xc_dom_check_gzip(xc_interface *xch, void *blob, size_t ziplen)
{
- unsigned char *gzlen;
size_t unziplen;
if ( ziplen < 6 )
/* not gzipped */
return 0;
- gzlen = blob + ziplen - 4;
- unziplen = (size_t)gzlen[3] << 24 | gzlen[2] << 16 | gzlen[1] << 8 | gzlen[0];
+ unziplen = get_unaligned_le32(blob + ziplen - 4);
if ( unziplen > XC_DOM_DECOMPRESS_MAX )
{
xc_dom_printf
#include <inttypes.h>
#include <stdint.h>
+#define XG_NEED_UNALIGNED
#include "xg_private.h"
#include "xg_dom_decompress.h"
unsigned long in_size,
unsigned long *out_size);
+#if !defined(__MINIOS__) || defined(XG_NEED_UNALIGNED)
+
+static inline unsigned int get_unaligned_le32(const uint8_t *buf)
+{
+ return ((unsigned int)buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
+}
+
+#endif /* !__MINIOS__ || XG_NEED_UNALIGNED */
+
unsigned long csum_page (void * page);
#define _PAGE_PRESENT 0x001
return le16_to_cpup(p);
}
-static inline u32 get_unaligned_le32(const void *p)
-{
- return le32_to_cpup(p);
-}
-
#endif
/*