Skip to content

Commit 0dae270

Browse files
authored
python-tqdm: patch CVE-2024-34062 (#9089)
1 parent 4a467cb commit 0dae270

2 files changed

Lines changed: 66 additions & 2 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
From b53348c73080b4edeb30b4823d1fa0d8d2c06721 Mon Sep 17 00:00:00 2001
2+
From: Casper da Costa-Luis <tqdm@cdcl.ml>
3+
Date: Wed, 1 May 2024 14:56:01 +0100
4+
Subject: [PATCH] cli: eval safety
5+
6+
- fixes GHSA-g7vv-2v7x-gj9p
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 1223d4977..7284f28d5 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,

SPECS/python-tqdm/python-tqdm.spec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ with "tqdm(iterable)", and you are done!
77
Summary: Fast, Extensible Progress Meter
88
Name: python-%{srcname}
99
Version: 4.63.1
10-
Release: 2%{?dist}
10+
Release: 3%{?dist}
1111
License: MPLv2.0 AND MIT
1212
Vendor: Microsoft Corporation
1313
Distribution: Mariner
1414
URL: https://github.com/tqdm/tqdm
1515
Source0: %{url}/archive/refs/tags/v%{version}.tar.gz#/%{srcname}-%{version}.tar.gz
16+
Patch0: CVE-2024-34062.patch
1617
BuildArch: noarch
1718

1819
%description %{_description}
@@ -30,7 +31,7 @@ BuildRequires: python3-wheel
3031
Python 3 version.
3132

3233
%prep
33-
%autosetup -n %{srcname}-%{version}
34+
%autosetup -n %{srcname}-%{version} -p1
3435

3536
%build
3637
%py3_build
@@ -55,6 +56,9 @@ tox -e setup.py
5556

5657

5758
%changelog
59+
* Mon May 13 2024 Jonathan Behrens <jbehrens@microsoft.com> - 4.63.1-3
60+
- Patch CVE-2024-34062
61+
5862
* Fri Dec 16 2022 Sam Meluch <sammeluch@microsoft.com> - 4.63.1-2
5963
- Update version of tox used for package tests
6064

0 commit comments

Comments
 (0)