zeek/spicy

Incorrect behavior with nested `&size` attributes

Closed this issue · 2 comments

@kkvarfordt reported an issue on Slack where code making use of nested &size attributes does not behave correctly:

module foo;

public type X = unit {
    x: Y[] &size=3;
};

type Y = unit {
    y: bytes &eod &size=2;
};
$ printf '\x01\x02\x03' | spicy-driver foo.spicy
[fatal error] terminating with uncaught exception of type spicy::rt::ParseError: &size amount not consumed (foo.spicy:4:13)

The expectation here would be that this parses into X { x: [ Y { y: b"\x01\x02"}, Y { y: b"\x03"} ] }. The behavior is the same if Y is inlined as x: (bytes &eod &size=2)[] &size=3.

This has been an issue since at least spicy-1.2.0.

I need to look more closely but I believe I just fixed this in the node-rewrite branch; didn't realize the same problem might have existed in main already.

Also backported to release/1.8.