-
-
Notifications
You must be signed in to change notification settings - Fork 706
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 Issue 23215: segfault in std.file.remove #8483
Conversation
|
Thanks for your pull request, @WebFreak001! Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#8483" |
|
IMO this is much more complicated than it should be. Doing this for all file APIs would be impractical. I suggest fix this with the least possible code by doing in - auto len = strlen(namez);
+ auto len = namez ? strlen(namez) : 0; |
|
that would mean the error messages will say |
For that, we should quote it somehow anyway, as special characters will mess up the message in a similar way. It also should be done consistently for all error messages in I've been using |
Also, not to start a bikeshed war, but in D that syntax means an array with one |
|
I have changed back the However I still think the exception improvement is valuable, so I moved the logic into the exception constructor and named it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM though I'm not a big fan of showing empty non-null strings as null, we should avoid computers gaslighting users where possible :)
d16dca1 to
f344c2a
Compare
|
squashed commits, made it only show |
std/file.d
Outdated
| import std.exception : collectExceptionMsg; | ||
|
|
||
| string filename = null; // e.g. as returned by File.tmpfile.name | ||
| assert( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assert fails currently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on linux it resulted in Bad address on my system, I adjusted the error messages now and test them on linux and windows. (message is platform-dependent) Otherwise just a check for FileException is used.
If the message is different on other linux distros (such as in the CI), I will also limit it to a prefix check there.
048ebfb to
060100a
Compare
060100a to
73589e6
Compare
would break as s is null and the removeImpl function has two arguments:
for dynamic ranges the D string is resolved from the tempCString by slicing the pointer up to strlen, however if the actual data is null, then the returned string by tempCString is a null pointer and attempting to strlen the null pointer segfaults.
Now a FileException is thrown, stating that a null string is not allowed and in the other methods that contained this strlen bug,
"[null]"is now used as filename in the FileException.