6f9995
From d135e45152a88b896b1d3e8770d5d59f694c2419 Mon Sep 17 00:00:00 2001
6f9995
From: Lumir Balhar <lbalhar@redhat.com>
6f9995
Date: Tue, 8 Jun 2021 10:08:49 +0200
6f9995
Subject: [PATCH] CVE-2021-3572
6f9995
6f9995
---
6f9995
 src/pip/_internal/vcs/git.py | 10 ++++++++--
6f9995
 1 file changed, 8 insertions(+), 2 deletions(-)
6f9995
6f9995
diff --git a/src/pip/_internal/vcs/git.py b/src/pip/_internal/vcs/git.py
6f9995
index a9c7fb6..b38625e 100644
6f9995
--- a/src/pip/_internal/vcs/git.py
6f9995
+++ b/src/pip/_internal/vcs/git.py
6f9995
@@ -142,9 +142,15 @@ class Git(VersionControl):
6f9995
             pass
6f9995
 
6f9995
         refs = {}
6f9995
-        for line in output.strip().splitlines():
6f9995
+        # NOTE: We do not use splitlines here since that would split on other
6f9995
+        #       unicode separators, which can be maliciously used to install a
6f9995
+        #       different revision.
6f9995
+        for line in output.strip().split("\n"):
6f9995
+            line = line.rstrip("\r")
6f9995
+            if not line:
6f9995
+                continue
6f9995
             try:
6f9995
-                sha, ref = line.split()
6f9995
+                sha, ref = line.split(" ", maxsplit=2)
6f9995
             except ValueError:
6f9995
                 # Include the offending line to simplify troubleshooting if
6f9995
                 # this error ever occurs.
6f9995
-- 
6f9995
2.31.1
6f9995