From 00a9cdd49df60b18233a957e497413533b6be3b9 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski <mail@justjanne.de> Date: Thu, 5 Jun 2025 01:03:47 +0200 Subject: [PATCH] Avoid crashing due to invalid sync messages --- .../libquassel/session/ProtocolHandler.kt | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/lib/src/main/java/de/kuschku/libquassel/session/ProtocolHandler.kt b/lib/src/main/java/de/kuschku/libquassel/session/ProtocolHandler.kt index dfb1d84a5..6a0a404b7 100644 --- a/lib/src/main/java/de/kuschku/libquassel/session/ProtocolHandler.kt +++ b/lib/src/main/java/de/kuschku/libquassel/session/ProtocolHandler.kt @@ -30,6 +30,7 @@ import de.kuschku.libquassel.quassel.syncables.interfaces.ISyncableObject import de.kuschku.libquassel.quassel.syncables.interfaces.invokers.Invokers import de.kuschku.libquassel.util.compatibility.LoggingHandler.Companion.log import de.kuschku.libquassel.util.compatibility.LoggingHandler.LogLevel.DEBUG +import de.kuschku.libquassel.util.compatibility.LoggingHandler.LogLevel.ERROR import java.io.Closeable abstract class ProtocolHandler( @@ -117,30 +118,34 @@ abstract class ProtocolHandler( open fun onInitStatusChanged(progress: Int, total: Int) {} override fun handle(f: SignalProxyMessage.SyncMessage): Boolean { - val obj = objectStorage.get(f.className, f.objectName) ?: if (isInitializing) { - syncQueue.add(f) - return true - } else null - - obj?.let { - val initQueue = toInit[it] - if (initQueue != null) { - initQueue.add(f) + try { + val obj = objectStorage.get(f.className, f.objectName) ?: if (isInitializing) { + syncQueue.add(f) return true - } + } else null + + obj?.let { + val initQueue = toInit[it] + if (initQueue != null) { + initQueue.add(f) + return true + } - val invoker = Invokers.get(ProtocolSide.CLIENT, f.className) - ?: throw IllegalArgumentException("Invalid classname: ${f.className}") - try { - currentCallClass = f.className - currentCallInstance = f.objectName - currentCallSlot = f.slotName - invoker.invoke(it, f.slotName, f.params) - } finally { - currentCallClass = "" - currentCallInstance = "" - currentCallSlot = "" + val invoker = Invokers.get(ProtocolSide.CLIENT, f.className) + ?: throw IllegalArgumentException("Invalid classname: ${f.className}") + try { + currentCallClass = f.className + currentCallInstance = f.objectName + currentCallSlot = f.slotName + invoker.invoke(it, f.slotName, f.params) + } finally { + currentCallClass = "" + currentCallInstance = "" + currentCallSlot = "" + } } + } catch (e: Exception) { + log(ERROR, "ProtocolHandler", "Exception occurred while processing $f", e) } return true } -- GitLab