diff --git a/sqfs/meta.c b/sqfs/meta.c index 6d8402e..8402597 100644 --- a/sqfs/meta.c +++ b/sqfs/meta.c @@ -41,6 +41,9 @@ static int write_dir(meta_writer_t *dm, node_t *node) count += 1; } + if (count > SQFS_MAX_DIR_ENT) + count = SQFS_MAX_DIR_ENT; + hdr.count = htole32(count - 1); hdr.start_block = htole32(c->inode_ref >> 16); hdr.inode_number = htole32(c->inode_num); diff --git a/sqfs/squashfs.h b/sqfs/squashfs.h index e0906e4..0869bee 100644 --- a/sqfs/squashfs.h +++ b/sqfs/squashfs.h @@ -10,6 +10,7 @@ #define SQFS_META_BLOCK_SIZE 8192 #define SQFS_DEFAULT_BLOCK_SIZE 131072 #define SQFS_DEVBLK_SIZE 4096 +#define SQFS_MAX_DIR_ENT 256 typedef struct { uint32_t magic;