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

Question: dealing with \u0000 in strings from jerry_string_to_utf8_char_buffer / jerry_string_to_char_buffer #2263

Closed
martijnthe opened this issue Apr 3, 2018 · 1 comment
Labels
question Raised question

Comments

@martijnthe
Copy link
Contributor

I realize this is not a JerryScript specific question, but I was wondering what people's approaches are towards dealing with strings from JS when they have a \u0000 unicode code point(s) in them. This ends up being encoded as a 0x00 byte, which happens to be the "terminator" of a C string as well.

I can imagine this being a source of bugs, esp. if assumptions are made in the C code w.r.t. the length given by jerry_get_(utf8_)string_length() vs strlen()/strlen_s().

Some approaches I can think of to deal with this:

  • Don't use anything from <string.h>, instead use a proper utf8 library to deal with strings that only takes in string data in the form of a pointer + length.
  • Truncate: just use the first 0x00 as the end and wipe all data after it just to be sure.
  • ...
@LaszloLango LaszloLango added the question Raised question label Apr 3, 2018
@rerobika
Copy link
Member

Closing the issue due to inactivity, please reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Raised question
Projects
None yet
Development

No branches or pull requests

3 participants