-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix #10958: buggy handling of embedded NUL chars #10991
Conversation
(I'm working on my |
I'd be very worried about the performance of doing an extra pass over every string to check for nuls (e.g. #10428). At least for number parsing this will probably need to be special-cased. |
The proposal is not to check every string for NULs, just the ones that we pass to C functions that expect NUL-terminated strings. There should, of course, be a way to circumvent that check and just produce a Cstring directly. I really don't think that most C APIs that accept NUL-terminated strings are used for large amounts of data. |
Rather than checking for NULs in some cases, for C routines that we wrote ourselves I am just adding an extra |
Sounds good. |
There are also cases where we are passing strings that are known not to contain
and I am leaving these as-is. |
Seems fine but seems like a weird place to eek out such a minuscule but of performance. |
fix #10958: buggy handling of embedded NUL chars
backported in b192bf0 |
This fixes the
length("\0w")
bug brought up in #10958 and a couple of related bugs. (cc @ScottPJones, @jiahao).Strings with embedded NUL chars are still silently truncated when passed to external C routines in many places (e.g. all of the libuv filesystem routines). My plan is to submit a separate PR defining new
Cstring
andCwstring
types to use inccall
(instead ofPtr{UInt8}
andPtr{Cwchar_t}
, respectively) for NUL-terminated strings, which throw an exception onconvert
for strings with embedded NULs.