52 lines
2.3 KiB
Diff
52 lines
2.3 KiB
Diff
From b3d543d7e16af844394316360ef1bf0b9d10f1b1 Mon Sep 17 00:00:00 2001
|
|
From: Illia Volochii <illia.volochii@gmail.com>
|
|
Date: Wed, 18 Jun 2025 16:25:01 +0300
|
|
Subject: [PATCH] Security fix for CVE-2025-50181
|
|
|
|
Co-authored-by: Seth Michael Larson <sethmichaellarson@gmail.com>
|
|
Co-authored-by: Quentin Pradet <quentin.pradet@gmail.com>
|
|
Co-authored-by: Seth Michael Larson <sethmichaellarson@gmail.com>
|
|
---
|
|
src/pip/_vendor/urllib3/poolmanager.py | 18 +++++++++++++++++-
|
|
1 file changed, 17 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/pip/_vendor/urllib3/poolmanager.py b/src/pip/_vendor/urllib3/poolmanager.py
|
|
index fb51bf7..a8de7c6 100644
|
|
--- a/src/pip/_vendor/urllib3/poolmanager.py
|
|
+++ b/src/pip/_vendor/urllib3/poolmanager.py
|
|
@@ -170,6 +170,22 @@ class PoolManager(RequestMethods):
|
|
|
|
def __init__(self, num_pools=10, headers=None, **connection_pool_kw):
|
|
RequestMethods.__init__(self, headers)
|
|
+ if "retries" in connection_pool_kw:
|
|
+ retries = connection_pool_kw["retries"]
|
|
+ if not isinstance(retries, Retry):
|
|
+ # When Retry is initialized, raise_on_redirect is based
|
|
+ # on a redirect boolean value.
|
|
+ # But requests made via a pool manager always set
|
|
+ # redirect to False, and raise_on_redirect always ends
|
|
+ # up being False consequently.
|
|
+ # Here we fix the issue by setting raise_on_redirect to
|
|
+ # a value needed by the pool manager without considering
|
|
+ # the redirect boolean.
|
|
+ raise_on_redirect = retries is not False
|
|
+ retries = Retry.from_int(retries, redirect=False)
|
|
+ retries.raise_on_redirect = raise_on_redirect
|
|
+ connection_pool_kw = connection_pool_kw.copy()
|
|
+ connection_pool_kw["retries"] = retries
|
|
self.connection_pool_kw = connection_pool_kw
|
|
self.pools = RecentlyUsedContainer(num_pools)
|
|
|
|
@@ -389,7 +405,7 @@ class PoolManager(RequestMethods):
|
|
kw["body"] = None
|
|
kw["headers"] = HTTPHeaderDict(kw["headers"])._prepare_for_method_change()
|
|
|
|
- retries = kw.get("retries")
|
|
+ retries = kw.get("retries", response.retries)
|
|
if not isinstance(retries, Retry):
|
|
retries = Retry.from_int(retries, redirect=redirect)
|
|
|
|
--
|
|
2.51.0
|
|
|