From 43fb3ca10aba7462eef06c5f268b17bf923b15ed Mon Sep 17 00:00:00 2001 From: yushijinhun Date: Thu, 2 May 2019 12:35:43 +0800 Subject: [PATCH] Fix illegal texturePayload may cause crash --- .../jackhuang/hmcl/auth/yggdrasil/YggdrasilService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilService.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilService.java index cac9ce7a6..b08e8fc81 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilService.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilService.java @@ -165,7 +165,13 @@ public class YggdrasilService { String encodedTextures = profile.getProperties().get("textures"); if (encodedTextures != null) { - TextureResponse texturePayload = fromJson(new String(Base64.getDecoder().decode(encodedTextures), UTF_8), TextureResponse.class); + byte[] decodedBinary; + try { + decodedBinary = Base64.getDecoder().decode(encodedTextures); + } catch (IllegalArgumentException e) { + throw new ServerResponseMalformedException(e); + } + TextureResponse texturePayload = fromJson(new String(decodedBinary, UTF_8), TextureResponse.class); return Optional.ofNullable(texturePayload.textures); } else { return Optional.empty();