Link to torrent: uncaught exception with files in relative data path #3

Open
opened 2022-10-22 00:48:58 +03:00 by bmn · 1 comment
bmn commented 2022-10-22 00:48:58 +03:00 (Migrated from github.com)

When using Link to torrent > Check Files,
and within the torrent there is 1+ file in the directory specified by "Torrent relative data path"
and the value given to "Torrent relative data path" does not end with a directory separator

...an uncaught exception occurs:

System.ArgumentOutOfRangeException: 'startIndex cannot be larger than length of string. Arg_ParamName_Name'

This doesn't affect most Bemani games (I think DDR A/20 is an exception) if the "data" directory is used, as recommended.

The cause AFAICT is that, when the first file in the torrent (within the relative path) is checked, RelativePath is given a separator if it doesn't have one, then its new length is used to try to get a substring from the file's directory path (which doesn't have a separator).

Related code:
https://github.com/Radioo/LincleLINK/blob/fe0287453637f69be77f34277ac4a4190344ffa8/LincleLINK/Logic/MainWindowLogic.cs#L535-L545

Also, if I understand the code correctly:
Exception on the first file aside, relPath.StartsWith(RelativePath) would return false for any other files in the relative data path.
Again, this doesn't affect most Bemani games, but any such files would not be handled.

When using Link to torrent > Check Files, and within the torrent there is 1+ file in the directory specified by "Torrent relative data path" and the value given to "Torrent relative data path" does not end with a directory separator ...an uncaught exception occurs: > System.ArgumentOutOfRangeException: 'startIndex cannot be larger than length of string. Arg_ParamName_Name' This doesn't affect most Bemani games (I think DDR A/20 is an exception) if the "data" directory is used, as recommended. The cause AFAICT is that, when the first file in the torrent (within the relative path) is checked, `RelativePath` is given a separator if it doesn't have one, then its new length is used to try to get a substring from the file's directory path (which doesn't have a separator). Related code: https://github.com/Radioo/LincleLINK/blob/fe0287453637f69be77f34277ac4a4190344ffa8/LincleLINK/Logic/MainWindowLogic.cs#L535-L545 Also, if I understand the code correctly: Exception on the first file aside, `relPath.StartsWith(RelativePath)` would return false for any other files in the relative data path. Again, this doesn't affect most Bemani games, but any such files would not be handled.
bmn commented 2022-10-23 03:22:04 +03:00 (Migrated from github.com)

Done a little more testing, and Link to torrent does skip any files that are in the same directory as the relative data path.

Done a little more testing, and Link to torrent does skip any files that are in the same directory as the relative data path.
Sign in to join this conversation.