-
Notifications
You must be signed in to change notification settings - Fork 3k
Michal/erts/fix-handling-of-short-paths-on-windows/OTP-19690 #9996
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
Michal/erts/fix-handling-of-short-paths-on-windows/OTP-19690 #9996
Conversation
CT Test Results 3 files 142 suites 49m 34s ⏱️ Results for commit b554434. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
60594a2
to
0faeb5e
Compare
0faeb5e
to
1cf0dba
Compare
erts/etc/win32/erl.c
Outdated
|
||
/* Chop of base name*/ | ||
for (p = dir+wcslen(dir)-1 ;p >= dir && *p != L'\\'; --p) | ||
; | ||
*p =L'\0'; | ||
p--; | ||
|
||
length = GetLongPathNameW(dir, NULL, 0); |
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.
We can get rid of _wcsdup(erlpath);
if we chop off the base name after getting the long path name, saving us from having to free(dir)
everywhere.
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.
I tried that, but here erlpath contains a path to file that can not exist (the erl.ini file), and in that case GetLongPathNameW will fail, if you ask it to convert possibly short path to long path of file/directory that does not exist, as pointed here:
If the function fails for any other reason, such as if the file does not exist, the return value is zero.
That's why I first chop of base name, and only then do the conversion.
erts/etc/win32/erl.c
Outdated
free(dir); | ||
error("Cannot find erlexec.dll"); | ||
} | ||
long_dir = (wchar_t *) malloc(length * sizeof(wchar_t)); |
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.
length
does not include the null terminator.
long_dir = (wchar_t *) malloc(length * sizeof(wchar_t)); | |
long_dir = (wchar_t *) malloc((length + 1) * sizeof(wchar_t)); |
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.
I think it does include it, here it says:
If the lpBuffer buffer is too small to contain the path, the return value is the size, in TCHARs, of the buffer that is required to hold the path and the terminating null character.
Doesn't it mean that space for null is included in the return we get?
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.
I've changed that to make it more clear, hopefully now it's ok.
1cf0dba
to
b554434
Compare
No description provided.