Fix access to invalid data on reception of packet with size 0
authorsapier <Sapier at GMX dot net>
Sat, 6 Sep 2014 15:41:40 +0000 (17:41 +0200)
committersapier <Sapier at GMX dot net>
Sat, 6 Sep 2014 15:42:34 +0000 (17:42 +0200)
src/connection.cpp

index 2f9339e6ae2da5977f2b0dadfff2c46797b9df09..bd0d872caf5a3f08c00b7825e5746b2a3181d973 100644 (file)
@@ -2143,7 +2143,9 @@ void ConnectionReceiveThread::receive()
                        LOG(derr_con<<m_connection->getDesc()
                                        <<"Receive(): Invalid incoming packet, "
                                        <<"size: " << received_size
-                                       <<", protocol: " << readU32(&packetdata[0]) <<std::endl);
+                                       <<", protocol: "
+                                       << ((received_size >= 4) ? readU32(&packetdata[0]) : -1)
+                                       << std::endl);
                        continue;
                }