|
|
|
@ -127,10 +127,15 @@ func (c *Container) MarshalBinary() []byte { |
|
|
|
|
|
|
|
|
|
// UnmarshalBinary decodes an EOF container.
|
|
|
|
|
func (c *Container) UnmarshalBinary(b []byte, isInitcode bool) error { |
|
|
|
|
return c.unmarshalSubContainer(b, isInitcode, true) |
|
|
|
|
return c.unmarshalContainer(b, isInitcode, true) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *Container) unmarshalSubContainer(b []byte, isInitcode bool, topLevel bool) error { |
|
|
|
|
// UnmarshalSubContainer decodes an EOF container that is inside another container.
|
|
|
|
|
func (c *Container) UnmarshalSubContainer(b []byte, isInitcode bool) error { |
|
|
|
|
return c.unmarshalContainer(b, isInitcode, false) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *Container) unmarshalContainer(b []byte, isInitcode bool, topLevel bool) error { |
|
|
|
|
if !hasEOFMagic(b) { |
|
|
|
|
return fmt.Errorf("%w: want %x", ErrInvalidMagic, eofMagic) |
|
|
|
|
} |
|
|
|
@ -275,7 +280,7 @@ func (c *Container) unmarshalSubContainer(b []byte, isInitcode bool, topLevel bo |
|
|
|
|
} |
|
|
|
|
subC := new(Container) |
|
|
|
|
end := min(idx+size, len(b)) |
|
|
|
|
if err := subC.unmarshalSubContainer(b[idx:end], isInitcode, false); err != nil { |
|
|
|
|
if err := subC.unmarshalContainer(b[idx:end], isInitcode, false); err != nil { |
|
|
|
|
if topLevel { |
|
|
|
|
return fmt.Errorf("%w in sub container %d", err, i) |
|
|
|
|
} |
|
|
|
|