File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed
Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 2121
2222"""
2323
24+ import ast as _ast
2425import io as _io
2526import os as _os
2627import collections
@@ -85,7 +86,7 @@ def _update(self):
8586 with f :
8687 for line in f :
8788 line = line .rstrip ()
88- key , pos_and_siz_pair = eval (line )
89+ key , pos_and_siz_pair = _ast . literal_eval (line )
8990 key = key .encode ('Latin-1' )
9091 self ._index [key ] = pos_and_siz_pair
9192
Original file line number Diff line number Diff line change @@ -217,6 +217,15 @@ def test_check_closed(self):
217217 self .assertEqual (str (cm .exception ),
218218 "DBM object has already been closed" )
219219
220+ def test_eval (self ):
221+ with open (_fname + '.dir' , 'w' ) as stream :
222+ stream .write ("str(print('Hacked!')), 0\n " )
223+ with support .captured_stdout () as stdout :
224+ with self .assertRaises (ValueError ):
225+ with dumbdbm .open (_fname ) as f :
226+ pass
227+ self .assertEqual (stdout .getvalue (), '' )
228+
220229 def tearDown (self ):
221230 _delete_files ()
222231
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ Core and Builtins
1313Library
1414-------
1515
16+ - Issue #22885: Fixed arbitrary code execution vulnerability in the dbm.dumb
17+ module. Original patch by Claudiu Popa.
18+
1619- Issue #23146: Fix mishandling of absolute Windows paths with forward
1720 slashes in pathlib.
1821
You can’t perform that action at this time.
0 commit comments