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

Remove extra byte in realm_string_t conversion #918

Merged
merged 2 commits into from
Sep 23, 2022
Merged

Conversation

nirinchev
Copy link
Member

@nirinchev nirinchev commented Sep 22, 2022

realm_string_t should never have been 0-terminated because it knows its own length. In fact, adding an extra empty byte will result in \u0000 being appended at the end of the string. I don't know how to test this since the only place it's used currently is for the password, but I've verified it manually by looking at the http request body.

@cla-bot cla-bot bot added the cla: yes label Sep 22, 2022
@nirinchev nirinchev requested review from desistefanova, blagoev and nielsenko and removed request for desistefanova September 22, 2022 16:49
@coveralls
Copy link

Pull Request Test Coverage Report for Build 3107262326

  • 0 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+5.5%) to 93.128%

Totals Coverage Status
Change from base Build 3097932778: 5.5%
Covered Lines: 393
Relevant Lines: 422

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 3107262326

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+5.5%) to 93.128%

Totals Coverage Status
Change from base Build 3097932778: 5.5%
Covered Lines: 393
Relevant Lines: 422

💛 - Coveralls

Copy link
Contributor

@nielsenko nielsenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List<int>.toCharPtr ends up calling

Pointer<Uint8> toUint8Ptr(Allocator allocator) {
    final nativeSize = length + 1;
    final result = allocator<Uint8>(nativeSize);
    final Uint8List native = result.asTypedList(nativeSize);
    native.setAll(0, this); // copy
    native.last = 0; // zero terminate
    return result.cast();
  }

i guess that need to be re-considered as well?

@nirinchev
Copy link
Member Author

List<int>.toCharPtr is mapping to char* which needs null termination otherwise we can't infer the length.

Copy link
Contributor

@blagoev blagoev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch.

@nirinchev nirinchev merged commit dd42979 into master Sep 23, 2022
@nirinchev nirinchev deleted the ni/realm-string-fix branch September 23, 2022 16:01
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants