[FIX] Потенциальные NPE

This commit is contained in:
Gravit 2020-09-26 20:13:52 +07:00
parent 32d7ca932a
commit 438133bce7
No known key found for this signature in database
GPG key ID: 98A079490768CCE5
4 changed files with 26 additions and 5 deletions

View file

@ -57,6 +57,13 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti
throw new AuthException("Password decryption error");
}
}
if(clientData.isAuth) {
if(LogHelper.isDevEnabled()) {
LogHelper.warning("Client %s double auth", clientData.username == null ? ip : clientData.username);
}
sendError("You are already logged in");
return;
}
AuthProviderPair pair;
if (auth_id == null || auth_id.isEmpty()) pair = server.config.getAuthProviderPair();
else pair = server.config.getAuthProviderPair(auth_id);

View file

@ -25,6 +25,10 @@ public void execute(ChannelHandlerContext ctx, Client client) {
sendError("Permissions denied");
return;
}
if(username == null || accessToken == null || serverID == null) {
sendError("Invalid request");
return;
}
boolean success;
try {
server.authHookManager.joinServerHook.hook(this, client);

View file

@ -3,6 +3,7 @@
import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.BatchProfileByUsernameRequestEvent;
import pro.gravit.launcher.profiles.PlayerProfile;
import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.socket.response.SimpleResponse;
import pro.gravit.utils.helper.LogHelper;
@ -20,14 +21,19 @@ public String getType() {
@Override
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
BatchProfileByUsernameRequestEvent result = new BatchProfileByUsernameRequestEvent();
if(list == null) {
sendError("Invalid request");
return;
}
result.playerProfiles = new PlayerProfile[list.length];
for (int i = 0; i < list.length; ++i) {
UUID uuid;
if (client.auth == null) {
LogHelper.warning("Client auth is null. Using default.");
uuid = server.config.getAuthProviderPair().handler.usernameToUUID(list[i].username);
} else uuid = client.auth.handler.usernameToUUID(list[i].username);
result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(uuid, list[i].username, list[i].client, client.auth.textureProvider);
AuthProviderPair pair = client.auth;
if (pair == null) {
pair = server.config.getAuthProviderPair();
}
uuid = pair.handler.usernameToUUID(list[i].username);
result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(uuid, list[i].username, list[i].client, pair.textureProvider);
}
sendResult(result);
}

View file

@ -23,6 +23,10 @@ public void execute(ChannelHandlerContext ctx, Client client) {
sendError("Access denied");
return;
}
if(dirName == null) {
sendError("Invalid request");
return;
}
HashedDir dir = server.updatesDirMap.get(dirName);
if (dir == null) {
sendError(String.format("Directory %s not found", dirName));