• Kirill Smelkov's avatar
    decoder: More mark exposing fixes · 7aeda71a
    Kirill Smelkov authored
    Continuing 5dbc8a1b (decoder: Don't allow mark to be returned as pickle
    result) I discovered that the mark object can be still exposed to user,
    but not directly. For example the following pickle:
    
    	"(\x85." // MARK + TUPLE1
    
    was creating Tuple{mark} and returning it just ok to the user.
    
    As marker must be used only internally it is invalid to do so. Python
    also forbids this:
    
            In [3]: s = b"(\x85."
    
            In [4]: dis(s)
                0: (    MARK
                1: \x85     TUPLE1
                2: .        STOP
            highest protocol among opcodes = 2
    
            In [5]: pickle.loads(s)
            ---------------------------------------------------------------------------
            UnpicklingError                           Traceback (most recent call last)
            <ipython-input-5-764e4625bc41> in <module>()
            ----> 1 pickle.loads(s)
    
            UnpicklingError: unexpected MARK found
    
    So let's close all (hopefully) holes where mark object could be returned to
    user in a similar way.
    7aeda71a
ogorek.go 26.8 KB