127 lines
3.3 KiB
Diff
127 lines
3.3 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(-)
|
|
|
|
diff --git a/squashfs-tools/unsquash-1.c b/squashfs-tools/unsquash-1.c
|
|
index acba821b..7598499d 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 c2d4f42b..0c8dfbb6 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 0746b3d4..86f62ba8 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 094caaa6..c04aa9ee 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 3a1b9e16..ff62dccc 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 7b590bd5..04be53cd 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 2e9201cd..5ecb2ab7 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
|