-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ICE from c_str with null character #16478
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
Comments
Fascinating find! I'm curious about what lead you to it. Is there a need to put null in these values? |
I had typed |
I marked this as easy since fixing this is probably just a matter of going to that exact code and emitting a proper error. Good starter bug. |
This is actually caused by CStrings failing the task if they have an interior null. source. Adding an error would fix this particular issue, but it wouldn't fix the underlying issue, so maybe a different course of action would be better. On a side note, what is the proper way to add an error to the compiler? |
@kaseyc What is the underlying issue? That we should always throw an error if a |
The underlying issue was that the checked versions of to_c_string and with_c_str crash on interior nulls. Doing an extra interior null check before calling them in this case doesn't help with this problem in other cases, and failing the task seems unnecessary, especially for the checked version. Perhaps the checked version could return an Option, and the unchecked would keep its current behavior. Edit: Alternately, a to_cstr_opt function could be added and used where necessary. |
Is anyone working on this? I'll take a crack at it this week if not. |
I am. I added a with_c_str_opt function (that had to wait on #17120), and am putting the finishing touches on the error messages. |
Add checks for null bytes in the value strings for the export_name and link_section attributes, reporting an error if any are found, before calling with_c_str on them. Fixes #16478
Both the export_name and link_section attributes will produce an ICE if '\0' is contained within the string.
Input
Output and Bakctrace
Version
The text was updated successfully, but these errors were encountered: