File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,10 +46,16 @@ def test(self):
4646 if i > self .min_iters and time .time () > stop_time :
4747 raise Exception ('looked too long and still failed' )
4848
49- # Generate raw random data
49+ # Generate raw random data. Note we do not open() the file multiple
50+ # times as that fails on windows; instead, seek to the start and
51+ # write from there, then later resize and flush. (We do all this to
52+ # avoid the slowdown of securely creating many tiny temp files, as
53+ # this loop may go on for a long time.)
54+ temp_dat .seek (0 )
5055 size = random .randint (1 , self .max_size )
51- with open (temp_dat .name , 'wb' ) as f :
52- f .write (bytes ([random .randint (0 , 255 ) for x in range (size )]))
56+ temp_dat .write (bytes ([random .randint (0 , 255 ) for x in range (size )]))
57+ temp_dat .truncate ()
58+ temp_dat .flush ()
5359
5460 # Generate the fuzz testcase from the random data + the initial
5561 # contents.
You can’t perform that action at this time.
0 commit comments