Absolute archive pathnames were allowed by default because no_abs_paths_flag was initialized to false. This could permit an archive to write files outside the intended extraction directory when cpio was run with elevated privileges.
Initialize no_abs_paths_flag to true so extraction is relative to the current directory unless --absolute-filenames is explicitly requested. Signed-off-by: Mohammed Mustafa <[email protected]> --- src/global.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/global.c b/src/global.c index c564fb2..0a97c2d 100644 --- a/src/global.c +++ b/src/global.c @@ -103,7 +103,7 @@ int quiet_flag = false; int only_verify_crc_flag = false; /* If true, don't use any absolute paths, prefix them by `./'. */ -int no_abs_paths_flag = false; +int no_abs_paths_flag = true; #ifdef DEBUG_CPIO /* If true, print debugging information. */ -- 2.53.0
