|
| 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 | + |
0 commit comments