Skip to content

Commit a4faa86

Browse files
[AUTO-CHERRYPICK] Patch python-tqdm for CVE-2024-34062 - branch 3.0-dev (#12505)
Co-authored-by: Kanishk Bansal <103916909+Kanishk-Bansal@users.noreply.github.com>
1 parent 79472ea commit a4faa86

2 files changed

Lines changed: 69 additions & 3 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
From 16eed9fc5bdc5e6de477a5329a3e6bd13548554a Mon Sep 17 00:00:00 2001
2+
From: Kanishk Bansal <kbkanishk975@gmail.com>
3+
Date: Thu, 6 Feb 2025 19:06:45 +0000
4+
Subject: [PATCH] Address CVE-2024-34062
5+
Upstream Patch Reference https://github.com/tqdm/tqdm/commit/4e613f84ed2ae029559f539464df83fa91feb316
6+
7+
---
8+
tqdm/cli.py | 33 ++++++++++++++++++++++-----------
9+
1 file changed, 22 insertions(+), 11 deletions(-)
10+
11+
diff --git a/tqdm/cli.py b/tqdm/cli.py
12+
index 1223d49..7284f28 100644
13+
--- a/tqdm/cli.py
14+
+++ b/tqdm/cli.py
15+
@@ -21,23 +21,34 @@ def cast(val, typ):
16+
return cast(val, t)
17+
except TqdmTypeError:
18+
pass
19+
- raise TqdmTypeError(val + ' : ' + typ)
20+
+ raise TqdmTypeError(f"{val} : {typ}")
21+
22+
# sys.stderr.write('\ndebug | `val:type`: `' + val + ':' + typ + '`.\n')
23+
if typ == 'bool':
24+
if (val == 'True') or (val == ''):
25+
return True
26+
- elif val == 'False':
27+
+ if val == 'False':
28+
return False
29+
- else:
30+
- raise TqdmTypeError(val + ' : ' + typ)
31+
- try:
32+
- return eval(typ + '("' + val + '")')
33+
- except Exception:
34+
- if typ == 'chr':
35+
- return chr(ord(eval('"' + val + '"'))).encode()
36+
- else:
37+
- raise TqdmTypeError(val + ' : ' + typ)
38+
+ raise TqdmTypeError(val + ' : ' + typ)
39+
+ if typ == 'chr':
40+
+ if len(val) == 1:
41+
+ return val.encode()
42+
+ if re.match(r"^\\\w+$", val):
43+
+ return eval(f'"{val}"').encode()
44+
+ raise TqdmTypeError(f"{val} : {typ}")
45+
+ if typ == 'str':
46+
+ return val
47+
+ if typ == 'int':
48+
+ try:
49+
+ return int(val)
50+
+ except ValueError as exc:
51+
+ raise TqdmTypeError(f"{val} : {typ}") from exc
52+
+ if typ == 'float':
53+
+ try:
54+
+ return float(val)
55+
+ except ValueError as exc:
56+
+ raise TqdmTypeError(f"{val} : {typ}") from exc
57+
+ raise TqdmTypeError(f"{val} : {typ}")
58+
59+
60+
def posix_pipe(fin, fout, delim=b'\\n', buf_size=256,
61+
--
62+
2.43.0
63+

SPECS/python-tqdm/python-tqdm.spec

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ with "tqdm(iterable)", and you are done!
77
Summary: Fast, Extensible Progress Meter
88
Name: python-%{srcname}
99
Version: 4.66.2
10-
Release: 1%{?dist}
10+
Release: 2%{?dist}
1111
License: MPLv2.0 AND MIT
1212
Vendor: Microsoft Corporation
1313
Distribution: Azure Linux
1414
URL: https://github.com/tqdm/tqdm
1515
Source0: %{pypi_source}
1616
BuildArch: noarch
17-
17+
Patch0: CVE-2024-34062.patch
1818
%description %{_description}
1919

2020
%package -n python3-%{srcname}
@@ -40,7 +40,7 @@ Python 3 version.
4040

4141
%prep
4242
export SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
43-
%autosetup -n %{srcname}-%{version}
43+
%autosetup -p1 -n %{srcname}-%{version}
4444
chmod -x tqdm/completion.sh
4545

4646
# https://github.com/tqdm/tqdm/pull/1292
@@ -90,6 +90,9 @@ pip3 install iniconfig \
9090

9191

9292
%changelog
93+
* Fri Feb 07 2025 Kanishk Bansal <kanbansal@microsoft.com> - 4.66.2-2
94+
- Patch CVE-2024-34062
95+
9396
* Tue Mar 26 2024 Henry Li <lihl@microsoft.com> - 4.66.2-1
9497
- Upgrade version to v4.66.2
9598
- Modify Source0

0 commit comments

Comments
 (0)