Skip to content

Fix bug with baseQDir in PathUtils.cpp#5689

Merged
Spekular merged 4 commits into
masterfrom
fixbaseqdir
Sep 30, 2020
Merged

Fix bug with baseQDir in PathUtils.cpp#5689
Spekular merged 4 commits into
masterfrom
fixbaseqdir

Conversation

@Spekular

Copy link
Copy Markdown
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

LmmsBot commented Sep 27, 2020

Copy link
Copy Markdown
🤖 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
Copy Markdown
Member

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

Comment thread src/core/PathUtil.cpp Outdated
@PhysSong

Copy link
Copy Markdown
Member

LGTM

Spekular and others added 2 commits September 29, 2020 12:29
Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>
@Spekular
Spekular requested a review from PhysSong September 29, 2020 12:24
@Spekular

Copy link
Copy Markdown
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