From 949437c6624ff25aa1126919040e70e35d5272de Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sat, 18 Mar 2023 00:51:58 +0100 Subject: [PATCH] backport pickle detection from @luarvique --- owrx/dsp.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/owrx/dsp.py b/owrx/dsp.py index 3abe02a2..62d55178 100644 --- a/owrx/dsp.py +++ b/owrx/dsp.py @@ -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"))