RubyMarshal icon indicating copy to clipboard operation
RubyMarshal copied to clipboard

list index out of range

Open HellishBro opened this issue 2 years ago • 2 comments

last line says result = self.objects[link_id]

file rubymarshal/reader.py line 169

HellishBro avatar Jul 23 '23 01:07 HellishBro

i made a workaround by commenting deleting the whole if token in tuple thing and just moved its inner statements out

HellishBro avatar Jul 23 '23 02:07 HellishBro

I receive the same error when trying to decode this stream: (hex)

0408753a1747656d3a3a53706563696669636174696f6e01d004085b17220a312e332e376908220661553a1147656d3a3a56657273696f6e5b06220a302e312e3049753a0954696d650d70931b8000000000063a1f406d61727368616c5f776974685f7574635f636f657263696f6e46220c53756d6d617279553a1547656d3a3a526571756972656d656e745b065b065b0722073e3d553b005b06220630553b085b065b065b0722073e3d553b005b062206302209727562795b0030220b20456d61696c5b06220c20417574686f7222002216687474703a2f2f676f6f676c652e636f6d54401d5b00

(bytes)

b'\x04\x08u:\x17Gem::Specification\x01\xd0\x04\x08[\x17"\n1.3.7i\x08"\x06aU:\x11Gem::Version[\x06"\n0.1.0Iu:\tTime\rp\x93\x1b\x80\x00\x00\x00\x00\x06:\x1f@marshal_with_utc_coercionF"\x0cSummaryU:\x15Gem::Requirement[\x06[\x06[\x07"\x07>=U;\x00[\x06"\x060U;\x08[\x06[\x06[\x07"\x07>=U;\x00[\x06"\x060"\truby[\x000"\x0b Email[\x06"\x0c Author"\x00"\x16http://google.comT@\x1d[\x00'

Gem::Specification is a UsrDef type and it uses Marshal.dump/load to stream its private data which looks like this:

b'\x04\x08[\x17"\n1.3.7i\x08"\x06aU:\x11Gem::Version[\x06"\n0.1.0Iu:\tTime\rp\x93\x1b\x80\x00\x00\x00\x00\x06:\x1f@marshal_with_utc_coercionF"\x0cSummaryU:\x15Gem::Requirement[\x06[\x06[\x07"\x07>=U;\x00[\x06"\x060U;\x08[\x06[\x06[\x07"\x07>=U;\x00[\x06"\x060"\truby[\x000"\x0b Email[\x06"\x0c Author"\x00"\x16http://google.comT@\x1d[\x00'

The @\x1d throws the out of range error. The same thing decodes fine with Ruby's Marshal.load. I assume that recursive Marshal.load/dump calls are allowed to share the list of objects to link to. (Non obvious from the code there.)

mdellweg avatar Jul 26 '23 14:07 mdellweg