openwrt/tools/squashfs4/patches/004-action-rework-strdupa-with-POSIX-strdup-and-free.patch
Christian Marangi 30f2d516ba
tools/squashfs4: add new tool for squashfs4 images
squashfs tool is finally reborn and correctly maintained.

Introduce the new version as a replacement for squasfs4kit as it was a
fork and also abandoned.

Add additional patch to add the missing feature present in squashfskit4
but still missing on this new project.

Backport each required patch that fix compilation error on macos.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2023-02-20 07:34:03 +01:00

38 lines
1.1 KiB
Diff

From 92e628ec0e26cf091d82356e3b74f73bedf4cfc8 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sat, 15 Oct 2022 00:11:20 +0200
Subject: [PATCH] action: rework strdupa with POSIX strdup and free
strdupa is not POSIX and cause compilation error on macos.
Fix this by using strdup and free.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
---
squashfs-tools/action.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
--- a/squashfs-tools/action.c
+++ b/squashfs-tools/action.c
@@ -2415,9 +2415,17 @@ static char *get_start(char *s, int n)
static int subpathname_fn(struct atom *atom, struct action_data *action_data)
{
- return fnmatch(atom->argv[0], get_start(strdupa(action_data->subpath),
- count_components(atom->argv[0])),
- FNM_PATHNAME|FNM_EXTMATCH) == 0;
+ char *s, *tmp;
+ int ret;
+
+ s = tmp = strdup(action_data->subpath);
+ tmp = get_start(tmp, count_components(atom->argv[0]));
+
+ ret = fnmatch(atom->argv[0], tmp, FNM_PATHNAME|FNM_EXTMATCH);
+
+ free(s);
+
+ return ret == 0;
}
/*