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

Wrong truncation of indexFileName in StartServer.cpp #4

Open
Qup42 opened this issue Apr 24, 2022 · 0 comments
Open

Wrong truncation of indexFileName in StartServer.cpp #4

Qup42 opened this issue Apr 24, 2022 · 0 comments

Comments

@Qup42
Copy link
Member

Qup42 commented Apr 24, 2022

Issue

When using a path that contains a /../ for the for the index the path is truncated in a wrong way.

Explanation

The responsible code is

string::size_type pos = indexFileName.find(".");
baseName = pos != string::npos ? indexFileName.substr(0, pos) : indexFileName;

It tries to truncate the path of the index file s.t. the file extension is removed. This is done by searching for the first occurence of . with find. If there is one everything after this first found dot is removed. This method fails if the path itself contains a /../. AFAIK even /./ in paths result in valid paths.

Example

E.g. take the path /local/data/vvz/tf-support/../completesearch-new/data/vvz/vvz.hybrid. The correct baseName would be /local/data/vvz/tf-support/../completesearch-new/data/vvz/vvz. But the code determines /local/data/vvz/tf-support/ as baseName

Possible fix

This could be possibly be fixed by replacing string::find with string::find_last_of.

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

No branches or pull requests

1 participant