mirror of
https://github.com/jketterl/openwebrx.git
synced 2026-01-09 10:10:01 +01:00
backport pickle detection from @luarvique
This commit is contained in:
parent
f0e6839816
commit
949437c662
|
|
@ -650,13 +650,17 @@ class DspManager(SdrSourceEventClient, ClientDemodulatorSecondaryDspEventClient)
|
|||
def _unpickle(self, callback):
|
||||
def unpickler(data):
|
||||
b = data.tobytes()
|
||||
# If we know it's not pickled, let us not unpickle
|
||||
if len(b) < 2 or b[0] != 0x80 or not 3 <= b[1] <= pickle.HIGHEST_PROTOCOL:
|
||||
callback(b.decode("ascii"))
|
||||
return
|
||||
|
||||
io = BytesIO(b)
|
||||
try:
|
||||
while True:
|
||||
callback(pickle.load(io))
|
||||
except EOFError:
|
||||
pass
|
||||
# TODO: this is not ideal. is there a way to know beforehand if the data will be pickled?
|
||||
except pickle.UnpicklingError:
|
||||
callback(b.decode("ascii"))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue