1414import os
1515import sys
1616import tempfile
17+ import zlib
1718
1819from lib .core .enums import MKSTEMP_PREFIX
1920from lib .core .exception import SqlmapSystemException
2021from lib .core .settings import BIGARRAY_CHUNK_SIZE
22+ from lib .core .settings import BIGARRAY_COMPRESS_LEVEL
2123
2224DEFAULT_SIZE_OF = sys .getsizeof (object ())
2325
@@ -80,8 +82,8 @@ def pop(self):
8082 if len (self .chunks [- 1 ]) < 1 :
8183 self .chunks .pop ()
8284 try :
83- with open (self .chunks [- 1 ], "rb" ) as fp :
84- self .chunks [- 1 ] = pickle .load ( fp )
85+ with open (self .chunks [- 1 ], "rb" ) as f :
86+ self .chunks [- 1 ] = pickle .loads ( zlib . decompress ( f . read ()) )
8587 except IOError , ex :
8688 errMsg = "exception occurred while retrieving data "
8789 errMsg += "from a temporary file ('%s')" % ex .message
@@ -101,8 +103,8 @@ def _dump(self, chunk):
101103 handle , filename = tempfile .mkstemp (prefix = MKSTEMP_PREFIX .BIG_ARRAY )
102104 self .filenames .add (filename )
103105 os .close (handle )
104- with open (filename , "w+b" ) as fp :
105- pickle .dump (chunk , fp , pickle .HIGHEST_PROTOCOL )
106+ with open (filename , "w+b" ) as f :
107+ f . write ( zlib . compress ( pickle .dumps (chunk , pickle .HIGHEST_PROTOCOL ), BIGARRAY_COMPRESS_LEVEL ) )
106108 return filename
107109 except (OSError , IOError ), ex :
108110 errMsg = "exception occurred while storing data "
@@ -119,8 +121,8 @@ def _checkcache(self, index):
119121
120122 if not (self .cache and self .cache .index == index ):
121123 try :
122- with open (self .chunks [index ], "rb" ) as fp :
123- self .cache = Cache (index , pickle .load ( fp ), False )
124+ with open (self .chunks [index ], "rb" ) as f :
125+ self .cache = Cache (index , pickle .loads ( zlib . decompress ( f . read ()) ), False )
124126 except IOError , ex :
125127 errMsg = "exception occurred while retrieving data "
126128 errMsg += "from a temporary file ('%s')" % ex .message
0 commit comments