]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix NUL termination issue on the test string by not actually printing the packet
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 8 May 2006 10:35:32 +0000 (10:35 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 8 May 2006 10:35:32 +0000 (10:35 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6350 d7cf8633-e32d-0410-b094-e92efae38249

lhnet.c

diff --git a/lhnet.c b/lhnet.c
index e244a6498d273cad15606e8d64ed7525974101a4..0b63b560758e1bce88607acd01fab3cfefbd09ae 100644 (file)
--- a/lhnet.c
+++ b/lhnet.c
@@ -769,7 +769,7 @@ int LHNET_Write(lhnetsocket_t *lhnetsocket, const void *content, int contentleng
 int main(int argc, char **argv)
 {
 #if 1
-       char *buffer = "socket to socket test successful", buffer2[1024];
+       char *buffer = "test", buffer2[1024];
        int blen = strlen(buffer);
        int b2len = 1024;
        lhnetsocket_t *sock1;
@@ -782,8 +782,6 @@ int main(int argc, char **argv)
        int test1;
        int test2;
 
-       strcpy(buffer2, "socket to socket test failed");
-
        printf("calling LHNET_Init\n");
        LHNET_Init();
 
@@ -806,8 +804,12 @@ int main(int argc, char **argv)
        usleep (100000);
 #endif
        printf("calling LHNET_Read on the second socket to read the packet sent from the first socket\n");
-       test2 = LHNET_Read(sock2, buffer2, b2len, &myaddy3);
-       Con_Printf("%s\n", buffer2);
+       test2 = LHNET_Read(sock2, buffer2, b2len - 1, &myaddy3);
+       if (test2 > 0)
+               Con_Printf("socket to socket test succeeded\n");
+       else
+               Con_Printf("socket to socket test failed\n");
+
 #ifdef WIN32
        printf("press any key to exit\n");
        getchar();