FS#3807 - Too long paths will result in an assert error during startup
Attached to Project:
OpenTTD
Opened by Peter Henschel (Progman) - Sunday, 02 May 2010, 17:58 GMT
Last edited by Remko Bijker (Rubidium) - Monday, 10 May 2010, 09:59 GMT
Opened by Peter Henschel (Progman) - Sunday, 02 May 2010, 17:58 GMT
Last edited by Remko Bijker (Rubidium) - Monday, 10 May 2010, 09:59 GMT
|
Detailsr19728
If you have very long paths inside ~/.openttd/ OpenTTD can crash if during startup a search path is generated which does not end in a /. This results in the following assertion Assertion failed at line 102 of /home/progman/openttd/trunk/src/os/unix/unix.cpp: path[strlen(path) - 1] == PATHSEPCHAR This can be reproduced by creating two symlinks in content_download/ with the names "recursion" and "recursion2" which points to "." (content_download). During startup the content_download/ directory is searched recursively for all files. With these symlinks it creates a path which is greater than the "path" array and so the path is truncated. This also means the trailing slash is cut off, so the assertion is thrown. In the attached strace log you see how the paths are generated and how a directory path is generated which does not end in a slash. The question of course is why would someone create such symlinks in a directory which is recursively loaded ;). Adding such of symlinks increase the load time during startup, specially if the names are very short (like "a"->. and "b"->.). These would result in an endless recursion lookup of a binary tree (only terminated by ELOOP (Too many levels of symbolic links)). Maybe a realpath() call can help here. |
This task depends upon
Closed by Remko Bijker (Rubidium)
Monday, 10 May 2010, 09:59 GMT
Reason for closing: Fixed
Additional comments about closing: Around r19780.
Monday, 10 May 2010, 09:59 GMT
Reason for closing: Fixed
Additional comments about closing: Around r19780.
Also realpath is basically an unusable function, at least without deliberately crashing older libcs and/or not working properly on non-POSIX 2008 but POSIX 2001 platforms.
In other words, this is going to require something more drastical.
A year has about 2^25 seconds, the universe is about 15 billion years old so 2^34 years. Which means it would take at least 2^240 times as long as the (current) universe has lasted, unless we assume that the universe is God's creation and is considerably less than 15 billion years old, but that still means at least 2^260 times as long.
As such I highly doubt it would have checked even near 2^350 combinations.