From 80975e0ce99fdc905edf9e3995cf65ac0cb4614b Mon Sep 17 00:00:00 2001 From: Spoike Date: Tue, 7 Sep 2004 23:18:20 +0000 Subject: [PATCH] Fixes a crash experienced with IPV6 and the serverbrowser (assignment to static strings = not good plan) git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@174 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/common/net_wins.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/engine/common/net_wins.c b/engine/common/net_wins.c index a90fe73f8..94115cdfd 100644 --- a/engine/common/net_wins.c +++ b/engine/common/net_wins.c @@ -418,6 +418,8 @@ qboolean NET_StringToSockaddr (char *s, struct sockaddr_qstorage *sadr) struct addrinfo udp6hint; int error; char *port; + char dupbase[256]; + int len; memset(&udp6hint, 0, sizeof(udp6hint)); udp6hint.ai_family = 0;//Any... AF_INET6; @@ -436,9 +438,12 @@ qboolean NET_StringToSockaddr (char *s, struct sockaddr_qstorage *sadr) port = NULL; if (port) { - *port = '\0'; - error = pgetaddrinfo(s, port+1, &udp6hint, &addrinfo); - *port = ':'; + len = port - s; + if (len >= sizeof(dupbase)) + len = sizeof(dupbase)-1; + strncpy(dupbase, s, len); + dupbase[len] = '\0'; + error = pgetaddrinfo(dupbase, port+1, &udp6hint, &addrinfo); } else error = EAI_NONAME;