orion / rpms / python3x-pip

Forked from rpms/python3x-pip 2 years ago
Clone
98d8ab
From 4f0099156245ed2873d6945d5e58db741e15836d Mon Sep 17 00:00:00 2001
98d8ab
From: Lumir Balhar <lbalhar@redhat.com>
98d8ab
Date: Tue, 8 Jun 2021 09:51:47 +0200
98d8ab
Subject: [PATCH] CVE-2021-3572
98d8ab
98d8ab
---
98d8ab
 src/pip/_internal/vcs/git.py | 10 ++++++++--
98d8ab
 1 file changed, 8 insertions(+), 2 deletions(-)
98d8ab
98d8ab
diff --git a/src/pip/_internal/vcs/git.py b/src/pip/_internal/vcs/git.py
98d8ab
index 92b8457..7b3cc4a 100644
98d8ab
--- a/src/pip/_internal/vcs/git.py
98d8ab
+++ b/src/pip/_internal/vcs/git.py
98d8ab
@@ -120,9 +120,15 @@ class Git(VersionControl):
98d8ab
         output = cls.run_command(['show-ref', rev], cwd=dest,
98d8ab
                                  show_stdout=False, on_returncode='ignore')
98d8ab
         refs = {}
98d8ab
-        for line in output.strip().splitlines():
98d8ab
+        # NOTE: We do not use splitlines here since that would split on other
98d8ab
+        #       unicode separators, which can be maliciously used to install a
98d8ab
+        #       different revision.
98d8ab
+        for line in output.strip().split("\n"):
98d8ab
+            line = line.rstrip("\r")
98d8ab
+            if not line:
98d8ab
+                continue
98d8ab
             try:
98d8ab
-                sha, ref = line.split()
98d8ab
+                sha, ref = line.split(" ", maxsplit=2)
98d8ab
             except ValueError:
98d8ab
                 # Include the offending line to simplify troubleshooting if
98d8ab
                 # this error ever occurs.
98d8ab
-- 
98d8ab
2.31.1
98d8ab