diff options
-rw-r--r-- | lib/sqfs/write_inode.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c index c78c852..f1f8abf 100644 --- a/lib/sqfs/write_inode.c +++ b/lib/sqfs/write_inode.c @@ -13,6 +13,8 @@ #include "sqfs/dir.h" #include "util/compat.h" +#include <string.h> + static int write_block_sizes(sqfs_meta_writer_t *ir, const sqfs_inode_generic_t *n) { @@ -29,24 +31,24 @@ static int write_block_sizes(sqfs_meta_writer_t *ir, static int write_dir_index(sqfs_meta_writer_t *ir, const sqfs_u8 *data, size_t count) { - sqfs_dir_index_t *ent, copy; + sqfs_dir_index_t ent; size_t len; int err; - while (count > sizeof(*ent)) { - ent = (sqfs_dir_index_t *)data; - data += sizeof(*ent); - count -= sizeof(*ent); - len = ent->size + 1; + while (count > sizeof(ent)) { + memcpy(&ent, data, sizeof(ent)); + data += sizeof(ent); + count -= sizeof(ent); + len = ent.size + 1; if (len > count) return SQFS_ERROR_CORRUPTED; - copy.start_block = htole32(ent->start_block); - copy.index = htole32(ent->index); - copy.size = htole32(ent->size); + ent.start_block = htole32(ent.start_block); + ent.index = htole32(ent.index); + ent.size = htole32(ent.size); - err = sqfs_meta_writer_append(ir, ©, sizeof(copy)); + err = sqfs_meta_writer_append(ir, &ent, sizeof(ent)); if (err) return err; |