From 2d9910d0fe3a411f5bec96ecc1d082c9c6e34153 Mon Sep 17 00:00:00 2001
From: Sam Doran <sdoran@redhat.com>
Date: Tue, 25 Feb 2020 15:13:36 -0500
Subject: [PATCH] win_unzip - ensure extraction path ends withpath sep

---
 lib/ansible/modules/windows/win_unzip.ps1 | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/ansible/modules/windows/win_unzip.ps1 b/lib/ansible/modules/windows/win_unzip.ps1
index abda148..7615784 100644
--- a/lib/ansible/modules/windows/win_unzip.ps1
+++ b/lib/ansible/modules/windows/win_unzip.ps1
@@ -54,6 +54,11 @@ Function Extract-Zip($src, $dest) {
         $entry_target_path = [System.IO.Path]::Combine($dest, $archive_name)
         $entry_dir = [System.IO.Path]::GetDirectoryName($entry_target_path)
 
+        # Ensure directory ends with path separator to prevent path traversal
+        if (-not $entry_dir.EndsWith([System.IO.Path]::DirectorySeparatorChar.ToString())) {
+            $entry_dir += [System.IO.Path]::DirectorySeparatorChar.ToString()
+	}
+
         if (-not (Test-Path -Path $entry_dir)) {
             New-Item -Path $entry_dir -ItemType Directory -WhatIf:$check_mode | Out-Null
             $result.changed = $true
-- 
2.23.0

