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:
Adam
2019-08-19 17:39:38 -04:00
parent 5fafa6faf1
commit 7d23b16ef4
2 changed files with 14 additions and 3 deletions

View File

@@ -55,11 +55,15 @@ class ClientConfigLoader
final RSConfig config = new RSConfig();
try (final Response response = RuneLiteAPI.CLIENT.newCall(request).execute();
final BufferedReader in = new BufferedReader(new InputStreamReader(response.body().byteStream())))
try (final Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
{
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)
{
int idx = str.indexOf('=');

View File

@@ -26,6 +26,7 @@
*/
package net.runelite.client.rs;
import com.google.common.base.Strings;
import com.google.common.hash.Hashing;
import com.google.common.io.ByteStreams;
import com.google.common.reflect.TypeToken;
@@ -110,6 +111,12 @@ public class ClientLoader implements Supplier<Applet>
try
{
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;
}
catch (IOException e)