rs: validate loaded config
If an empty body or error response is received, the client would attempt to use a null code base and initial jar, which immediately failed
This commit is contained in:
@@ -55,11 +55,15 @@ class ClientConfigLoader
|
|||||||
|
|
||||||
final RSConfig config = new RSConfig();
|
final RSConfig config = new RSConfig();
|
||||||
|
|
||||||
try (final Response response = RuneLiteAPI.CLIENT.newCall(request).execute();
|
try (final Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||||
final BufferedReader in = new BufferedReader(new InputStreamReader(response.body().byteStream())))
|
|
||||||
{
|
{
|
||||||
String str;
|
if (!response.isSuccessful())
|
||||||
|
{
|
||||||
|
throw new IOException("Unsuccessful response: " + response.message());
|
||||||
|
}
|
||||||
|
|
||||||
|
String str;
|
||||||
|
final BufferedReader in = new BufferedReader(new InputStreamReader(response.body().byteStream()));
|
||||||
while ((str = in.readLine()) != null)
|
while ((str = in.readLine()) != null)
|
||||||
{
|
{
|
||||||
int idx = str.indexOf('=');
|
int idx = str.indexOf('=');
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.rs;
|
package net.runelite.client.rs;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.hash.Hashing;
|
import com.google.common.hash.Hashing;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
@@ -110,6 +111,12 @@ public class ClientLoader implements Supplier<Applet>
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
config = ClientConfigLoader.fetch(host);
|
config = ClientConfigLoader.fetch(host);
|
||||||
|
|
||||||
|
if (Strings.isNullOrEmpty(config.getCodeBase()) || Strings.isNullOrEmpty(config.getInitialJar()) || Strings.isNullOrEmpty(config.getInitialClass()))
|
||||||
|
{
|
||||||
|
throw new IOException("Invalid or missing jav_config");
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
|||||||
Reference in New Issue
Block a user