mktemp: fix PrefixContainsDirSeparator verification

This commit is contained in:
ZauJulio 2023-02-16 17:48:23 -03:00
parent f610f33aa7
commit af4ce911c8
No known key found for this signature in database
GPG key ID: 5AC499A308A063B8

View file

@ -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() {