Skip to content

Commit

Permalink
Add patch to allow partclone to build.
Browse files Browse the repository at this point in the history
  • Loading branch information
rluzuriaga committed Nov 24, 2023
1 parent eaa68f3 commit a3dc0e1
Showing 1 changed file with 117 additions and 0 deletions.
117 changes: 117 additions & 0 deletions patch/filesystem/fs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
diff --git a/Config.in b/Config.in
index d3bf6000ca..b3e0c9ff64 100644
--- a/Config.in
+++ b/Config.in
@@ -687,6 +687,24 @@ config BR2_GLOBAL_PATCH_DIR

menu "Advanced"

+config BR2_COMPILER_PARANOID_UNSAFE_PATH
+ bool "paranoid check of library/header paths"
+ default y
+ help
+ By default, when this option is disabled, when the Buildroot
+ cross-compiler will encounter an unsafe library or header path
+ (such as /usr/include, or /usr/lib), the compiler will display
+ a warning.
+
+ By enabling this option, this warning is turned into an error,
+ which will completely abort the build when such unsafe paths
+ are encountered.
+
+ Note that this mechanism is available for both the internal
+ toolchain (through the toolchain wrapper and binutils patches)
+ and external toolchain backends (through the toolchain
+ wrapper).
+
config BR2_FORCE_HOST_BUILD
bool "Force the building of host dependencies"
help
diff --git a/package/Makefile.in b/package/Makefile.in
index 7e6ae19559..8ffabdea55 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -428,8 +428,9 @@ else ifeq ($(BR2_SHARED_STATIC_LIBS),y)
SHARED_STATIC_LIBS_OPTS = --enable-static --enable-shared
endif

-# Used by our binutils patches.
+ifeq ($(BR2_COMPILER_PARANOID_UNSAFE_PATH),y)
export BR_COMPILER_PARANOID_UNSAFE_PATH=enabled
+endif

include package/pkg-download.mk
include package/pkg-autotools.mk
diff --git a/support/config-fragments/minimal.config b/support/config-fragments/minimal.config
index 3430fcce11..71344e2c69 100644
--- a/support/config-fragments/minimal.config
+++ b/support/config-fragments/minimal.config
@@ -4,4 +4,5 @@ BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
# BR2_TARGET_ROOTFS_TAR is not set
+BR2_COMPILER_PARANOID_UNSAFE_PATH=y
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
diff --git a/toolchain/toolchain-wrapper.c b/toolchain/toolchain-wrapper.c
index f66e588bfd..8d856bac44 100644
--- a/toolchain/toolchain-wrapper.c
+++ b/toolchain/toolchain-wrapper.c
@@ -157,6 +157,7 @@ static const struct str_len_s unsafe_opts[] = {
*/
static void check_unsafe_path(const char *arg,
const char *path,
+ int paranoid,
int arg_has_path)
{
const struct str_len_s *p;
@@ -165,12 +166,14 @@ static void check_unsafe_path(const char *arg,
if (strncmp(path, p->str, p->len))
continue;
fprintf(stderr,
- "%s: ERROR: unsafe header/library path used in cross-compilation: '%s%s%s'\n",
+ "%s: %s: unsafe header/library path used in cross-compilation: '%s%s%s'\n",
program_invocation_short_name,
+ paranoid ? "ERROR" : "WARNING",
arg,
arg_has_path ? "" : "' '", /* close single-quote, space, open single-quote */
arg_has_path ? "" : path); /* so that arg and path are properly quoted. */
- exit(1);
+ if (paranoid)
+ exit(1);
}
}

@@ -245,6 +248,8 @@ int main(int argc, char **argv)
char *progpath = argv[0];
char *basename;
char *env_debug;
+ char *paranoid_wrapper;
+ int paranoid;
int ret, i, count = 0, debug = 0, found_shared = 0;

/* Debug the wrapper to see arguments it was called with.
@@ -463,6 +468,12 @@ int main(int argc, char **argv)
#endif
}

+ paranoid_wrapper = getenv("BR_COMPILER_PARANOID_UNSAFE_PATH");
+ if (paranoid_wrapper && strlen(paranoid_wrapper) > 0)
+ paranoid = 1;
+ else
+ paranoid = 0;
+
/* Check for unsafe library and header paths */
for (i = 1; i < argc; i++) {
const struct str_len_s *opt;
@@ -479,9 +490,9 @@ int main(int argc, char **argv)
i++;
if (i == argc)
break;
- check_unsafe_path(argv[i-1], argv[i], 0);
+ check_unsafe_path(argv[i-1], argv[i], paranoid, 0);
} else
- check_unsafe_path(argv[i], argv[i] + opt->len, 1);
+ check_unsafe_path(argv[i], argv[i] + opt->len, paranoid, 1);
}
}

0 comments on commit a3dc0e1

Please sign in to comment.