forked from I2P_Developers/i2p.i2p
i2psnark: Fix SIOOBE on bad announce URL (ticket #1823)
This commit is contained in:
@ -893,11 +893,16 @@ public class TrackerClient implements Runnable {
|
|||||||
} catch (URISyntaxException use) {
|
} catch (URISyntaxException use) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
String path = url.getPath();
|
||||||
|
if (path == null || !path.startsWith("/"))
|
||||||
|
return false;
|
||||||
return "http".equals(url.getScheme()) && url.getHost() != null &&
|
return "http".equals(url.getScheme()) && url.getHost() != null &&
|
||||||
(url.getHost().endsWith(".i2p") || url.getHost().equals("i2p"));
|
(url.getHost().endsWith(".i2p") || url.getHost().equals("i2p"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This also validates the URL.
|
||||||
|
*
|
||||||
* @param ann an announce URL non-null
|
* @param ann an announce URL non-null
|
||||||
* @return a Hash for i2p hosts only, null otherwise
|
* @return a Hash for i2p hosts only, null otherwise
|
||||||
* @since 0.9.5
|
* @since 0.9.5
|
||||||
@ -914,8 +919,12 @@ public class TrackerClient implements Runnable {
|
|||||||
String host = url.getHost();
|
String host = url.getHost();
|
||||||
if (host == null)
|
if (host == null)
|
||||||
return null;
|
return null;
|
||||||
if (host.endsWith(".i2p"))
|
if (host.endsWith(".i2p")) {
|
||||||
|
String path = url.getPath();
|
||||||
|
if (path == null || !path.startsWith("/"))
|
||||||
|
return null;
|
||||||
return ConvertToHash.getHash(host);
|
return ConvertToHash.getHash(host);
|
||||||
|
}
|
||||||
if (host.equals("i2p")) {
|
if (host.equals("i2p")) {
|
||||||
String path = url.getPath();
|
String path = url.getPath();
|
||||||
if (path == null || path.length() < 517 ||
|
if (path == null || path.length() < 517 ||
|
||||||
@ -941,6 +950,10 @@ public class TrackerClient implements Runnable {
|
|||||||
int consecutiveFails;
|
int consecutiveFails;
|
||||||
int seenPeers;
|
int seenPeers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param a must be a valid http URL with a path
|
||||||
|
* @param p true if primary
|
||||||
|
*/
|
||||||
public TCTracker(String a, boolean p)
|
public TCTracker(String a, boolean p)
|
||||||
{
|
{
|
||||||
announce = a;
|
announce = a;
|
||||||
|
Reference in New Issue
Block a user