-
Notifications
You must be signed in to change notification settings - Fork 712
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
docs: specify s2n_blob growable conditions #4943
base: main
Are you sure you want to change the base?
Conversation
utils/s2n_blob.h
Outdated
/* An allocated blob (e.g.`s2n_alloc`) is always growable. A "reference" | ||
* blob (from `s2n_init`) is never growable. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether this behavior was actually intentional 🤔 Kind of seems like it was an artifact of aliasing "s2n_alloc" to "s2n_realloc", probably for unrelated reasons.
Separating "growable" from "allocated" definitely makes sense in the stuffer, because "allocated" indicates whether or not the data needs to be freed, and "growable" indicates whether insufficient space should be an error or lead to an allocation (usually it's an error).
But I guess with a blob, it wouldn't grow automatically, and you'd have to explicitly call "realloc", which is pretty strong indicator that you want to allocate more memory :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, I think "growable" is just a very confusing concept for the blob, and don't understand a scenario where
- a stuffer would have
growable=false
- a blob would have
growable=true
or vice versa.
I opened #4944 to track further "normalization".
* I have apparently forgotten my truth tables :'(
allows for zero-size allocated blobs being growable
Once again, boolean logic evades me :'(
Co-authored-by: maddeleine <[email protected]>
Co-authored-by: maddeleine <[email protected]>
Description of changes:
The
growable
field on s2n_blob does have a purpose, but it took me a lot of investigation to figure out what that purpose was. So I added a comment!If we ever decide that zero-sized allocation are forbidden, we can remove it.
Testing:
All unit tests should continue to pass.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.