From d18e6f49447e6562848be8ea6a1ac82a47cb80e3 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Fri, 25 Sep 2020 01:08:28 +0200 Subject: [PATCH] Fixed bug whereby DConnection thread would crash due to incorrect slicing indices --- source/dnetd/dconnection.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/dnetd/dconnection.d b/source/dnetd/dconnection.d index eca00bd..5cac824 100644 --- a/source/dnetd/dconnection.d +++ b/source/dnetd/dconnection.d @@ -169,7 +169,7 @@ public class DConnection : Thread byte usernameLength = message.data[1]; /* Get the username and password */ - string username = cast(string)message.data[2..usernameLength]; + string username = cast(string)message.data[2..cast(ulong)2+usernameLength]; string password = cast(string)message.data[cast(ulong)2+usernameLength..message.data.length]; /* Authenticate */ @@ -182,6 +182,7 @@ public class DConnection : Thread /* Set the type of this connection to `client` */ connType = ConnectionType.CLIENT; + hasAuthed = true; /* Encode the reply */ byte[] reply = [status];