squashfs-tools/0006-CVE-2021-41072.patch
2021-11-09 20:42:27 +08:00

113 lines
2.5 KiB
Diff

From 80b8441a37fcf8bf07dacf24d9d6c6459a0f6e36 Mon Sep 17 00:00:00 2001
From: Phillip Lougher <phillip@squashfs.org.uk>
Date: Sun, 12 Sep 2021 19:58:19 +0100
Subject: [PATCH] unsquashfs: use squashfs_closedir() to delete directory
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
---
squashfs-tools/unsquash-1.c | 3 +--
squashfs-tools/unsquash-1234.c | 11 +++++++++--
squashfs-tools/unsquash-2.c | 3 +--
squashfs-tools/unsquash-3.c | 3 +--
squashfs-tools/unsquash-4.c | 3 +--
squashfs-tools/unsquashfs.c | 7 -------
squashfs-tools/unsquashfs.h | 1 +
7 files changed, 14 insertions(+), 17 deletions(-)
--- a/squashfs-tools/unsquash-1.c
+++ b/squashfs-tools/unsquash-1.c
@@ -316,8 +316,7 @@ static struct dir *squashfs_opendir(unsi
return dir;
corrupted:
- free(dir->dirs);
- free(dir);
+ squashfs_closedir(dir);
return NULL;
}
--- a/squashfs-tools/unsquash-1234.c
+++ b/squashfs-tools/unsquash-1234.c
@@ -25,8 +25,8 @@
* unsquash-4.
*/
-#define TRUE 1
-#define FALSE 0
+#include "unsquashfs.h"
+
/*
* Check name for validity, name should not
* - be ".", "./", or
@@ -56,3 +56,10 @@ int check_name(char *name, int size)
return TRUE;
}
+
+
+void squashfs_closedir(struct dir *dir)
+{
+ free(dir->dirs);
+ free(dir);
+}
--- a/squashfs-tools/unsquash-2.c
+++ b/squashfs-tools/unsquash-2.c
@@ -417,8 +417,7 @@ static struct dir *squashfs_opendir(unsi
return dir;
corrupted:
- free(dir->dirs);
- free(dir);
+ squashfs_closedir(dir);
return NULL;
}
--- a/squashfs-tools/unsquash-3.c
+++ b/squashfs-tools/unsquash-3.c
@@ -444,8 +444,7 @@ static struct dir *squashfs_opendir(unsi
return dir;
corrupted:
- free(dir->dirs);
- free(dir);
+ squashfs_closedir(dir);
return NULL;
}
--- a/squashfs-tools/unsquash-4.c
+++ b/squashfs-tools/unsquash-4.c
@@ -380,8 +380,7 @@ static struct dir *squashfs_opendir(unsi
return dir;
corrupted:
- free(dir->dirs);
- free(dir);
+ squashfs_closedir(dir);
return NULL;
}
--- a/squashfs-tools/unsquashfs.c
+++ b/squashfs-tools/unsquashfs.c
@@ -1290,13 +1290,6 @@ unsigned int *offset, unsigned int *type
}
-void squashfs_closedir(struct dir *dir)
-{
- free(dir->dirs);
- free(dir);
-}
-
-
char *get_component(char *target, char **targname)
{
char *start;
--- a/squashfs-tools/unsquashfs.h
+++ b/squashfs-tools/unsquashfs.h
@@ -264,4 +264,5 @@ extern long long *alloc_index_table(int)
/* unsquash-1234.c */
extern int check_name(char *, int);
+extern void squashfs_closedir(struct dir *);
#endif