From af4ce911c8315e3f339ea809ccf04b65ef834075 Mon Sep 17 00:00:00 2001 From: ZauJulio Date: Thu, 16 Feb 2023 17:48:23 -0300 Subject: [PATCH] mktemp: fix PrefixContainsDirSeparator verification --- src/uu/mktemp/src/mktemp.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index 390c77bfa..fed946577 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -281,7 +281,11 @@ impl Params { .join(prefix_from_template) .display() .to_string(); - if options.treat_as_template && prefix.contains(MAIN_SEPARATOR) { + + // Check that the prefix is valid. + let prefix_of_template = Path::new(prefix_from_template).display().to_string(); + + if options.treat_as_template && prefix_of_template.contains(MAIN_SEPARATOR) { return Err(MkTempError::PrefixContainsDirSeparator(options.template)); } if tmpdir.is_some() && Path::new(prefix_from_template).is_absolute() {