mirror of
https://github.com/TeamAmaze/AmazeFileManager.git
synced 2026-10-17 05:08:00 +08:00
Additional check of port number validity
Must be 1..65535
This commit is contained in:
@@ -110,7 +110,13 @@ class NetCopyConnectionInfo(url: String) {
|
||||
* this branch must be integer
|
||||
*/
|
||||
try {
|
||||
it[7].toInt()
|
||||
// Need to make sure port number is in range
|
||||
if (it[7].toInt() in 1..65535) {
|
||||
it[7].toInt()
|
||||
} else {
|
||||
LOGGER.warn("Port number is out of range: ${it[7]}")
|
||||
0
|
||||
}
|
||||
} catch (e: NumberFormatException) {
|
||||
LOGGER.warn("Unable to parse port number: ${it[7]}", e)
|
||||
0
|
||||
|
||||
@@ -346,6 +346,9 @@ class NetCopyConnectionInfoTest {
|
||||
NetCopyConnectionInfo("ssh://user:pass@127.0.0.1:21097/a/b/c/d/e").run {
|
||||
assertEquals(21097, this.port)
|
||||
}
|
||||
NetCopyConnectionInfo("ssh://user:pass@127.0.0.1:99999/a/b/c/d/e").run {
|
||||
assertEquals(0, this.port)
|
||||
}
|
||||
NetCopyConnectionInfo("ssh://user:pass@127.0.0.1/a/b/c/d/e").run {
|
||||
assertEquals(0, this.port)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user