From 24eaa1e0797ec8b1cc48a027634edd1166164377 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Fri, 6 Nov 2020 00:58:25 +0100 Subject: [PATCH] add even more prints --- src/Network/Auth.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Network/Auth.cpp b/src/Network/Auth.cpp index bef57fd..dca66d1 100644 --- a/src/Network/Auth.cpp +++ b/src/Network/Auth.cpp @@ -39,15 +39,19 @@ std::string Rcv(SOCKET TCPSock){ } // RealSize is big-endian, so we convert it to host endianness RealSize = ntohl(RealSize); + debug(std::string("got ") + std::to_string(RealSize) + " as size"); if (RealSize > 7000) { error(Sec("Larger than allowed TCP packet received")); return ""; } - RealSize = std::min(RealSize, 7000); char buf[7000]; - std::fill_n(buf, sizeof(buf), 0); + std::fill_n(buf, 7000, 0); BytesRcv = recv(TCPSock, buf, RealSize, 0); - if (BytesRcv <= 0)return ""; + if (BytesRcv != RealSize) { + debug("expected " + std::to_string(RealSize) + " bytes, got " + std::to_string(BytesRcv) + " instead"); + } + if (BytesRcv <= 0) + return ""; return std::string(buf); } std::string GetRole(const std::string &DID){