Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The wrap method on generated flyweights is failing to validate maxValue is sufficient #59

Open
cmebarrow opened this issue Jan 19, 2018 · 0 comments

Comments

@cmebarrow
Copy link

cmebarrow commented Jan 19, 2018

It is therefore in some cases reading memory beyond maxLimit. The wrap method on the Flyweight class itself should verify that maxLimit is greater than offset. Generated wrap method should validate that maxLimit - offset is at least large enough to accommodate all required and default values.

Taking the DataFW as an example, as generated from the following IDL:

        struct Frame
        {
            int64 streamId;
        }
       
        struct AuthorizedFrame extends core::stream::Frame
        {
            int64 authorization = 0;
        }

        struct Data extends core::stream::AuthorizedFrame [0x00000002]
        {
            uint8 flags = 1;            // 0x01 FIN
            int64 groupId;
            int32 padding;
            int32 length;
            octets[length] payload = null;
            octets extension;
        }

calling DataFW.wrap(buffer, offset, maxLimit) should throw an exception if maxLimit - offset is not at least 8 + 8 + 1 + 8 + 4 + 4 = 33. Currently it will just attempt to interpret bytes going beyond maxLimit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant