squashfs-tools/6002-unsquashfs-add-definition-for-SQUASHFS_DIR_COUNT.patch
2019-09-30 11:17:34 -04:00

75 lines
2.6 KiB
Diff

From 6f10093abf055508d0b7c65b2e2135b95c0ecc02 Mon Sep 17 00:00:00 2001
From: renxudong <renxudong1@huawei.com>
Date: Sun, 11 Aug 2019 01:03:58 -0400
Subject: [PATCH 2/8] unsquashfs-add-definition-for-SQUASHFS_DIR_COUNT
---
squashfs-tools/squashfs_fs.h | 3 +++
squashfs-tools/unsquash-1.c | 4 ++--
squashfs-tools/unsquash-3.c | 4 ++--
squashfs-tools/unsquash-4.c | 4 ++--
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/squashfs-tools/squashfs_fs.h b/squashfs-tools/squashfs_fs.h
index 791fe12..5407597 100644
--- a/squashfs-tools/squashfs_fs.h
+++ b/squashfs-tools/squashfs_fs.h
@@ -47,6 +47,9 @@
/* Max length of filename (not 255) */
#define SQUASHFS_NAME_LEN 256
+/* Max value for directory header count */
+#define SQUASHFS_DIR_COUNT 256
+
#define SQUASHFS_INVALID ((long long) 0xffffffffffff)
#define SQUASHFS_INVALID_FRAG ((unsigned int) 0xffffffff)
#define SQUASHFS_INVALID_XATTR ((unsigned int) 0xffffffff)
diff --git a/squashfs-tools/unsquash-1.c b/squashfs-tools/unsquash-1.c
index 6209243..1cbf1b1 100644
--- a/squashfs-tools/unsquash-1.c
+++ b/squashfs-tools/unsquash-1.c
@@ -263,8 +263,8 @@ struct dir *squashfs_opendir_1(unsigned int block_start, unsigned int offset,
"%d, %d directory entries\n", bytes, dir_count);
bytes += sizeof(dirh);
- /* dir_count should never be larger than 256 */
- if(dir_count > 256)
+ /* dir_count should never be larger than SQUASHFS_DIR_COUNT */
+ if(dir_count > SQUASHFS_DIR_COUNT)
goto corrupted;
while(dir_count--) {
diff --git a/squashfs-tools/unsquash-3.c b/squashfs-tools/unsquash-3.c
index 92e18c5..dc530bb 100644
--- a/squashfs-tools/unsquash-3.c
+++ b/squashfs-tools/unsquash-3.c
@@ -341,8 +341,8 @@ struct dir *squashfs_opendir_3(unsigned int block_start, unsigned int offset,
"%d, %d directory entries\n", bytes, dir_count);
bytes += sizeof(dirh);
- /* dir_count should never be larger than 256 */
- if(dir_count > 256)
+ /* dir_count should never be larger than SQUASHFS_DIR_COUNT */
+ if(dir_count > SQUASHFS_DIR_COUNT)
goto corrupted;
while(dir_count--) {
diff --git a/squashfs-tools/unsquash-4.c b/squashfs-tools/unsquash-4.c
index cf30ec1..58eb17d 100644
--- a/squashfs-tools/unsquash-4.c
+++ b/squashfs-tools/unsquash-4.c
@@ -310,8 +310,8 @@ struct dir *squashfs_opendir_4(unsigned int block_start, unsigned int offset,
"%d, %d directory entries\n", bytes, dir_count);
bytes += sizeof(dirh);
- /* dir_count should never be larger than 256 */
- if(dir_count > 256)
+ /* dir_count should never be larger than SQUASHFS_DIR_COUNT */
+ if(dir_count > SQUASHFS_DIR_COUNT)
goto corrupted;
while(dir_count--) {
--
1.8.3.1