Fix error handling on inconsistent client ready message
authorsapier <Sapier at GMX dot net>
Wed, 16 Jul 2014 18:01:00 +0000 (20:01 +0200)
committersapier <Sapier at GMX dot net>
Wed, 16 Jul 2014 18:01:00 +0000 (20:01 +0200)
Fix android makefile to provide a correct dummy githash if detection fails

build/android/Makefile
src/server.cpp

index 38a3cbb0ee37531ad6be663e51cc850a0963ec4f..6528e839cab814e830bae3d9202adf9d6a9690de 100644 (file)
@@ -691,7 +691,11 @@ $(ROOT)/jni/src/android_version.h :
        echo "#define VERSION_PATCH_ORIG $$(cat ${ROOT}/../../CMakeLists.txt |     \
        grep ^set\(VERSION_PATCH\ | sed 's/)/ /' | awk '{print $$2;}')"            \
        >> ${ROOT}/jni/src/android_version.h;                                      \
-       echo "#define CMAKE_VERSION_GITHASH \"$$(git rev-parse --short=8 HEAD)\""  \
+       export GITHASH=$$(git rev-parse --short=8 HEAD);                           \
+       if [ "x$$GITHASH" = "x" ] ; then                                           \
+               export GITHASH=gUnknown;                                               \
+       fi;                                                                        \
+       echo "#define CMAKE_VERSION_GITHASH \"$$GITHASH\""                         \
        >> ${ROOT}/jni/src/android_version.h;                                      \
        echo "#define CMAKE_VERSION_STRING STR(VERSION_MAJOR)\".\"STR(VERSION_MINOR)\
        \".\"STR(VERSION_PATCH)"                                                   \
index 1e644ce6ce3a672a5f4d414f63409a66940e0fad..40857f84d72954b673c90ddda6af9d5b91cd83f2 100644 (file)
@@ -1732,14 +1732,20 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
 
                if (playersao == NULL) {
                        errorstream
-                               << "TOSERVER_CLIENT_READY stage 2 client init failed for peer "
+                               << "TOSERVER_CLIENT_READY stage 2 client init failed for peer_id: "
                                << peer_id << std::endl;
+                       m_con.DisconnectPeer(peer_id);
                        return;
                }
 
 
-               if(datasize < 2+8)
+               if(datasize < 2+8) {
+                       errorstream
+                               << "TOSERVER_CLIENT_READY client sent inconsistent data, disconnecting peer_id: "
+                               << peer_id << std::endl;
+                       m_con.DisconnectPeer(peer_id);
                        return;
+               }
 
                m_clients.setClientVersion(
                                peer_id,