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

String::concat(char*, size_t) doesn't support non-null terminated views #8200

Closed
5 of 6 tasks
paulocsanz opened this issue Jul 7, 2021 · 2 comments · Fixed by #8198
Closed
5 of 6 tasks

String::concat(char*, size_t) doesn't support non-null terminated views #8200

paulocsanz opened this issue Jul 7, 2021 · 2 comments · Fixed by #8198

Comments

@paulocsanz
Copy link
Contributor

paulocsanz commented Jul 7, 2021

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Problem Description

If a non-null terminated char* view (like std::array<char, 32> md5 as storage) is passed to String::concat it currently crashes, because it's triggering UB by reading after the end of the buffer. This is the only way the current String API could allow adding a non-null terminated string to String, all the rest depends on strlen. So it's kinda important to the non-null terminated view use case.

@mcspr
Copy link
Collaborator

mcspr commented Jul 7, 2021

If a non-null terminated char* view (like std::array<char, 32> md5 as storage) is passed to String::concat it currently crashes

Could you share the specific crash condition though? idk if this has anything to do with nullchars, as we can read whatever with memcpy, if it is in the valid memory range? e.g. if array is at 0x40000000 - 32, reading past 0x40000000 will cause the crash unless it does aligned reads

edit: rephrasing - memmove_P resolves to either plain memmove or memcpy_P, depending on the pointer address value. Original pointer selects memmove, but reading past 0x4.... requires the other variant.

@paulocsanz
Copy link
Contributor Author

I'm not sure, but I was doing something close to that, we don't use the stack at the 4kb unused sys stack, so we put some std::arrays in its place and the array that seemed to be the problem was the last one in the struct, but it didn't even reach 0x3FFFF000, so it may just be a misdiagnose of mine.

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

Successfully merging a pull request may close this issue.

2 participants