-
Notifications
You must be signed in to change notification settings - Fork 154
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
Makes TChDirDialog on Linux handle native Linux paths (and fix crash) #141
base: master
Are you sure you want to change the base?
Makes TChDirDialog on Linux handle native Linux paths (and fix crash) #141
Conversation
…inux path (eg /home), makes TDirListBox work properly on Linux (no C:\ drives etc) Fixes segfault on Linux if you call TDirListBox::newDirectory() with a real Unix-style path. Makes the TChDirDialog support native Linux paths (no simulated C:\ drive etc).
This does not fix the crash for me. ASAN still reports an issue.
trimEndSeparator( curDir );
** strcpy( dirInput->data, curDir );
dirInput->drawView(); After cherry-picking d0d645f onto d1fa783, ASAN still flags the very same line. |
Hi everyone! First of all, @MookThompson, excuse me for not having replied in a very long time. Thanks for sharing your solution. In my opinion, However, I agree that there is no point in displaying drive letters. I fixed this in 545bc7d. Switching from backslashes to forward slashes requires making deeper changes, so I am skipping that for now. Compatibility with Windows paths is tied to the public specification of the Turbo Vision-provided path manipulation functions ( Secondly, @jengelh, thanks for the report although the crash you described was not related to the changes in this pull request. Nevertheless, I attempted to fix it in e5b8d3f, although I'm afraid that Cheers. |
Hi Magiblot,
Thanks for looking at it. I don't blame you for kicking this particular can down the road - it definitely seems like one of those threads you start pulling on that will cause lots of stuff to unravel 🙂.
I agree that using TChDirDialog to change the working directory of a process is exceptionally rare nowadays, but I was trying to use (misuse?) it as the basis for a 'Choose directory' dialog, which is still a common requirement (SHBrowseForFolder is the equivalent Windows Common Control). I've ended up hacking together my own dialog that does this specific job in a cross-platform way (along with a File Open dialog that's more like the modern Windows one), so it's not an issue for me.
Cheers,
Mark
…________________________________
From: magiblot ***@***.***>
Sent: 22 May 2024 00:36
To: magiblot/tvision ***@***.***>
Cc: MookThompson ***@***.***>; Mention ***@***.***>
Subject: Re: [magiblot/tvision] Makes TChDirDialog on Linux handle native Linux paths (and fix crash) (PR #141)
Hi everyone!
First of all, @MookThompson<https://github.com/MookThompson>, excuse me for not having replied in a very long time. Thanks for sharing your solution. In my opinion, TChDirDialog implements an outdated concept that no modern user expects to find in (barely) any application these days. That's why I didn't bother integrating Unix paths into it. I still think it's not worth spending much effort into it.
However, I agree that there is no point in displaying drive letters. I fixed this in 545bc7d<545bc7d>. Switching from backslashes to forward slashes requires making deeper changes, so I am skipping that for now. Compatibility with Windows paths is tied to the public specification of the Turbo Vision-provided path manipulation functions (fexpand, getCurDir...). Since it is highly discouraged to use these functions anyway (e.g. they rely on buffers limited to MAXPATH characters), I prefer to at least preserve their expected behavior. For example, getCurDir is expected to return a path including a drive letter, so the changes in your solution could break code elsewhere.
Secondly, @jengelh<https://github.com/jengelh>, thanks for the report although the crash you described was not related to the changes in this pull request. Nevertheless, I attempted to fix it in e5b8d3f<e5b8d3f>, although I'm afraid that TChDirDialog (and all the code related to file paths in general) is still vulnerable to memory safety issues due to the prevalence of unsafe string manipulation operations.
Cheers.
—
Reply to this email directly, view it on GitHub<#141 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AN6NQ5XPUK26YIHO342O5TTZDPK6ZAVCNFSM6AAAAABCUQIIZKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRTGU4TKMZRGQ>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Hi magliblot,
For the record, here are the hacky changes I made to get the TChDirDialog to work on Linux with native paths (and not crash when doing so). For my use, I don't need/want the Linux TChDirDialog to handle Windows paths, so it doesn't (eg it should accept names with the valid-on-Linux '\' char in it without assuming that's a directory separator). Because I don't need to support Windows paths on Linux, it's also switched based on the existing _TV_UNIX #define, rather than some runtime flag.
The fix for the crash is the "if ( end == NULL )" check in source/tvision/tdirlist.cpp.
As discussed, there could well be other places where the 'Windows paths on Linux' is still assumed - I've just done what I needed to get the TChDirDialog up and running as I wanted it.
Hope this helps you do it properly if you get chance to look at it at some point.
Mark