completesearch icon indicating copy to clipboard operation
completesearch copied to clipboard

Wrong truncation of indexFileName in StartServer.cpp

Open Qup42 opened this issue 2 years ago • 0 comments

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 https://github.com/ad-freiburg/completesearch/blob/bfb452b405a4d2690ee22ee785655f99abbae781/src/server/StartCompletionServer.cpp#L429-L430 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.

Qup42 avatar Apr 24 '22 11:04 Qup42