diff options
author | tron <tron@openttd.org> | 2006-04-14 18:52:08 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-04-14 18:52:08 +0000 |
commit | c9580160b29ef8e4aac248264b0817ae6a16b5c2 (patch) | |
tree | fec17c99a5eed250ddc9941b018808954b1ec178 | |
parent | 4118b66322a135a4af2316de5878c8dc713ae52c (diff) | |
download | openttd-c9580160b29ef8e4aac248264b0817ae6a16b5c2.tar.xz |
(svn r4416) Remove a pointless buffer copy and use strlcpy() instead of snprintf("%s")
-rw-r--r-- | network_udp.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/network_udp.c b/network_udp.c index 5ee2bb6ea..5cfd6615b 100644 --- a/network_udp.c +++ b/network_udp.c @@ -549,15 +549,12 @@ NetworkGameList *NetworkUDPQueryServer(const char* host, unsigned short port) struct sockaddr_in out_addr; Packet *p; NetworkGameList *item; - char hostname[NETWORK_HOSTNAME_LENGTH]; // No UDP-socket yet.. if (_udp_client_socket == INVALID_SOCKET) if (!NetworkUDPListen(&_udp_client_socket, 0, 0, true)) return NULL; - ttd_strlcpy(hostname, host, sizeof(hostname)); - out_addr.sin_family = AF_INET; out_addr.sin_port = htons(port); out_addr.sin_addr.s_addr = NetworkResolveHost(host); @@ -565,8 +562,8 @@ NetworkGameList *NetworkUDPQueryServer(const char* host, unsigned short port) // Clear item in gamelist item = NetworkGameListAddItem(inet_addr(inet_ntoa(out_addr.sin_addr)), ntohs(out_addr.sin_port)); memset(&item->info, 0, sizeof(item->info)); - snprintf(item->info.server_name, sizeof(item->info.server_name), "%s", hostname); - snprintf(item->info.hostname, sizeof(item->info.hostname), "%s", hostname); + ttd_strlcpy(item->info.server_name, host, lengthof(item->info.server_name)); + ttd_strlcpy(item->info.hostname, host, lengthof(item->info.hostname)); item->online = false; // Init the packet |