Skip to content

Commit

Permalink
Fix unaligned data reference in LZS
Browse files Browse the repository at this point in the history
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Feb 27, 2015
1 parent 5552b96 commit c786621
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lzs.c
Expand Up @@ -179,7 +179,7 @@ int lzs_compress(unsigned char *dst, int dstlen, const unsigned char *src, int s
*/
#define HASH_BITS 16
#define HASH_TABLE_SIZE (1ULL << HASH_BITS)
#define HASH(p) (*(uint16_t *)(p))
#define HASH(p) (((struct oc_packed_uint16_t *)p)->d)

/*
* There are two data structures for tracking the history. The first
Expand Down
4 changes: 4 additions & 0 deletions lzstest.c
Expand Up @@ -17,6 +17,10 @@

#define __OPENCONNECT_INTERNAL_H__

struct oc_packed_uint16_t {
unsigned short d;
} __attribute__((packed));

int lzs_decompress(unsigned char *dst, int dstlen, const unsigned char *src, int srclen);
int lzs_compress(unsigned char *dst, int dstlen, const unsigned char *src, int srclen);

Expand Down

0 comments on commit c786621

Please sign in to comment.