summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/squashfs-tools/squashfs-tools/CVE-2021-41072-requisite-1.patch
blob: d01b5c68711682bbe3dc3f2f7cc4d752f48d66ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
The commit is required by the fix for CVE-2021-41072.

Upstream-Status: Backport [https://github.com/plougher/squashfs-tools/commit/80b8441]

Signed-off-by: Kai Kang <kai.kang@windriver.com>

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(-)

diff --git a/squashfs-tools/unsquash-1.c b/squashfs-tools/unsquash-1.c
index acba821..7598499 100644
--- a/squashfs-tools/unsquash-1.c
+++ b/squashfs-tools/unsquash-1.c
@@ -373,8 +373,7 @@ static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offse
 	return dir;
 
 corrupted:
-	free(dir->dirs);
-	free(dir);
+	squashfs_closedir(dir);
 	return NULL;
 }
 
diff --git a/squashfs-tools/unsquash-1234.c b/squashfs-tools/unsquash-1234.c
index c2d4f42..0c8dfbb 100644
--- 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);
+}
diff --git a/squashfs-tools/unsquash-2.c b/squashfs-tools/unsquash-2.c
index 0746b3d..86f62ba 100644
--- a/squashfs-tools/unsquash-2.c
+++ b/squashfs-tools/unsquash-2.c
@@ -465,8 +465,7 @@ static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offse
 	return dir;
 
 corrupted:
-	free(dir->dirs);
-	free(dir);
+	squashfs_closedir(dir);
 	return NULL;
 }
 
diff --git a/squashfs-tools/unsquash-3.c b/squashfs-tools/unsquash-3.c
index 094caaa..c04aa9e 100644
--- a/squashfs-tools/unsquash-3.c
+++ b/squashfs-tools/unsquash-3.c
@@ -499,8 +499,7 @@ static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offse
 	return dir;
 
 corrupted:
-	free(dir->dirs);
-	free(dir);
+	squashfs_closedir(dir);
 	return NULL;
 }
 
diff --git a/squashfs-tools/unsquash-4.c b/squashfs-tools/unsquash-4.c
index 3a1b9e1..ff62dcc 100644
--- a/squashfs-tools/unsquash-4.c
+++ b/squashfs-tools/unsquash-4.c
@@ -436,8 +436,7 @@ static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offse
 	return dir;
 
 corrupted:
-	free(dir->dirs);
-	free(dir);
+	squashfs_closedir(dir);
 	return NULL;
 }
 
diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c
index 7b590bd..04be53c 100644
--- a/squashfs-tools/unsquashfs.c
+++ b/squashfs-tools/unsquashfs.c
@@ -1350,13 +1350,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;
diff --git a/squashfs-tools/unsquashfs.h b/squashfs-tools/unsquashfs.h
index 2e9201c..5ecb2ab 100644
--- a/squashfs-tools/unsquashfs.h
+++ b/squashfs-tools/unsquashfs.h
@@ -291,4 +291,5 @@ extern long long *alloc_index_table(int);
 
 /* unsquash-1234.c */
 extern int check_name(char *, int);
+extern void squashfs_closedir(struct dir *);
 #endif
-- 
2.17.1