Skip to content
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 bug with baseQDir in PathUtils.cpp #5689

Merged
merged 4 commits into from
Sep 30, 2020
Merged

Fix bug with baseQDir in PathUtils.cpp #5689

merged 4 commits into from
Sep 30, 2020

Conversation

Spekular
Copy link
Member

Originally posted by @PhysSong in #5117 (comment):

If base is Absolute, baseQDir(base) will point to the working directory. It will result in undefined behaviors.


Opening for easier discussion, even this solution is flawed:

Better than before, but that may result in getting foo/bar for /foo/bar which will be interpreted as old-style relative path.

If `base` is `Absolute`, `baseQDir(base)` will point to the working directory. It will result in undefined behaviors.

_Originally posted by @PhysSong in #5117 (comment)

Opening for easier discussion, even this solution is flawed:

> Better than before, but that may result in getting foo/bar for /foo/bar which will be interpreted as old-style relative path.
@Spekular Spekular added this to the 1.3 milestone Sep 27, 2020
@LmmsBot
Copy link

LmmsBot commented Sep 27, 2020

🤖 Hey, I'm @LmmsBot from github.com/lmms/bot and I made downloads for this pull request, click me to make them magically appear! 🎩

Linux

Windows

macOS

🤖
{"platform_name_to_artifacts": {"Linux": [{"artifact": {"title": {"title": "(AppImage)", "platform_name": "Linux"}, "link": {"link": "https://9096-15778896-gh.circle-artifacts.com/0/lmms-1.2.3-716%2Bg603c380-linux-x86_64.AppImage"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/9096?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "Windows": [{"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://9095-15778896-gh.circle-artifacts.com/0/lmms-1.2.3-716%2Bg603c3802c-mingw-win32.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/9095?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://9094-15778896-gh.circle-artifacts.com/0/lmms-1.2.3-716%2Bg603c3802c-mingw-win64.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/9094?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/2l02i3m96h2fkflh/artifacts/build/lmms-1.2.2-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/35465119"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/23t3ckskfa1uh74w/artifacts/build/lmms-1.2.2-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/35465119"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/075bosmpchupw970/artifacts/build/lmms-1.2.2-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/35465120"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/hij011so77dagq7e/artifacts/build/lmms-1.2.2-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/35465120"}], "macOS": [{"artifact": {"title": {"title": "", "platform_name": "macOS"}, "link": {"link": "https://9097-15778896-gh.circle-artifacts.com/0/lmms-1.2.3-716%2Bg603c3802c-mac10.13.dmg"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/9097?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}]}, "commit_sha": "603c3802c2795e90bb76b8ca5a05ccbe23a62615"}

@PhysSong
Copy link
Member

I think relativeOrAbsolute() shouldn't use relativePath if base == Absolute in order to fix the issue I mentioned.

src/core/PathUtil.cpp Outdated Show resolved Hide resolved
@PhysSong
Copy link
Member

LGTM

Spekular and others added 2 commits September 29, 2020 12:29
Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>
@Spekular
Copy link
Member Author

Just realized the previous fix didn't do what I intended it to, whoops.

@Spekular Spekular merged commit cc87dfb into master Sep 30, 2020
@Spekular Spekular deleted the fixbaseqdir branch September 30, 2020 09:27
sdasda7777 pushed a commit to sdasda7777/lmms that referenced this pull request Jun 28, 2022
* Fix relativeOrAbsolute bug with baseQDir in PathUtils.cpp

If `base` is `Absolute`, `baseQDir(base)` will point to the working directory. It will result in undefined behaviors.

To fix this, update relativeOrAbsolute to explicitly return an absolute path when the target base is Absolute. Also make baseQDir return QDir::root() for Absolute base instead of QDir(""), because the latter represents the working directory.

Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants