From 91753026dca5ff73287d42b4eab6e60ff8d00dcc Mon Sep 17 00:00:00 2001 From: ac-stef Date: Tue, 8 Sep 2015 11:51:02 +0200 Subject: [PATCH] fix enet issue #31 easier to fix the library than every use of the functions --- source/enet/unix.c | 2 ++ source/enet/win32.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/source/enet/unix.c b/source/enet/unix.c index 06052882..be621915 100644 --- a/source/enet/unix.c +++ b/source/enet/unix.c @@ -132,6 +132,7 @@ enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameL char * addr = inet_ntoa (* (struct in_addr *) & address -> host); if (addr != NULL) strncpy (name, addr, nameLength); + name[nameLength - 1] = '\0'; else #endif return -1; @@ -165,6 +166,7 @@ enet_address_get_host (const ENetAddress * address, char * name, size_t nameLeng return enet_address_get_host_ip (address, name, nameLength); strncpy (name, hostEntry -> h_name, nameLength); + name[nameLength - 1] = '\0'; return 0; } diff --git a/source/enet/win32.c b/source/enet/win32.c index 1701be38..a5ac061f 100644 --- a/source/enet/win32.c +++ b/source/enet/win32.c @@ -80,6 +80,7 @@ enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameL if (addr == NULL) return -1; strncpy (name, addr, nameLength); + name[nameLength - 1] = '\0'; return 0; } @@ -96,6 +97,7 @@ enet_address_get_host (const ENetAddress * address, char * name, size_t nameLeng return enet_address_get_host_ip (address, name, nameLength); strncpy (name, hostEntry -> h_name, nameLength); + name[nameLength - 1] = '\0'; return 0; }