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

AVRO-3221: Verify NUL termination on set_string_len and make buffer more compact #1352

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ashdnazg
Copy link

@ashdnazg ashdnazg commented Oct 6, 2021

Previously all size bytes were copied from the given string,
including the required NUL terminator, and then another NUL terminator
was appended in avro_raw_string_set_length.
Now the existence of the NUL terminator is verified, allowing to
catch programmer mistakes and then only size - 1 bytes are copied
before appending the NUL terminator.

Make sure you have checked all steps below.

Jira

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:

Test that setting a non-null terminated string fails.

Commits

  • My commits all reference Jira issues in their subject lines. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

@github-actions github-actions bot added the C label Oct 6, 2021
@ashdnazg ashdnazg force-pushed the avoid-double-null branch 3 times, most recently from 08c873e to cab98b4 Compare October 17, 2021 19:48
Previously all `size` bytes were copied from the given string,
including the required NUL terminator, and then another NUL terminator
was appended in avro_raw_string_set_length.
Now the existence of the NUL terminator is verified, allowing to
catch programmer mistakes and then a NUL terminator is only appended if
one hadn't existed in the first place (as would be in the case of bytes).
@RyanSkraba RyanSkraba changed the title AVRO-3221 Verify NUL termination on set_string_len and make buffer more compact AVRO-3221: Verify NUL termination on set_string_len and make buffer more compact Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant