google / google/emboss

`IsComplete` may check `requires`, making checking before writing to a 0-initialized buffer difficult.

Open
#240 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
92
Forks
30
PR merge metrics
No merged PRs in 30d

Description

In the C++ runtime if a type has a `requires` clause and that field is used in determining the size of the struct, `IsComplete` appears to check that `requires` clause. This means a generic approach of 0-initializing a buffer then checking `IsComplete` breaks for structs that have fields that exclude 0, for instance.

Workarounds involve either leaving it unchecked and manually confirming (defeating the purpose of checks like `IsComplete`) or splitting definitions into fixed-size portions and variable-sized portions.

We should evaluate whether `IsComplete` should ignore the `requires` for these fields, or if there's a good reason we need to ensure the consistency of these fields, potentially provide a verifier that ensures that all fixed-size, fixed-location portions of the struct are safe to write to, allowing the client code to call `IsComplete` once they've initialized those to ensure the entire struct is safe to write to.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.