Changeset - r10504:4c7c33ade813
[Not reviewed]
master
0 2 0
rubidium - 15 years ago 2008-12-28 21:07:45
rubidium@openttd.org
(svn r14759) -Fix (r14730): tab completion causing out-of-bounds read.
2 files changed with 9 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/network/core/tcp.h
Show inline comments
 
@@ -127,7 +127,7 @@ static inline bool IsValidNetworkClientS
 
	return (uint)index < GetNetworkClientSocketPoolSize() && GetNetworkClientSocket(index)->IsValid();
 
}
 

	
 
#define FOR_ALL_CLIENT_SOCKETS_FROM(d, start) for (d = (start < GetNetworkClientSocketPoolSize() ? GetNetworkClientSocket(start) : NULL); d != NULL; d = (d->index + 1U < GetNetworkClientSocketPoolSize()) ? GetNetworkClientSocket(d->index + 1U) : NULL) if (d->IsValid())
 
#define FOR_ALL_CLIENT_SOCKETS_FROM(d, start) for (d = GetNetworkClientSocket(start); d != NULL; d = (d->index + 1U < GetNetworkClientSocketPoolSize()) ? GetNetworkClientSocket(d->index + 1U) : NULL) if (d->IsValid())
 
#define FOR_ALL_CLIENT_SOCKETS(d) FOR_ALL_CLIENT_SOCKETS_FROM(d, 0)
 

	
 
typedef NetworkClientSocket NetworkTCPSocketHandler;
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -300,12 +300,14 @@ struct NetworkChatWindow : public QueryS
 

	
 
		/* First, try clients */
 
		if (*item < MAX_CLIENT_SLOTS) {
 
			/* Skip inactive clients */
 
			NetworkClientInfo *ci;
 
			FOR_ALL_CLIENT_INFOS_FROM(ci, *item + 1) break;
 
			if (ci != NULL) {
 
				*item = ci->index;
 
				return ci->client_name;
 
			if (*item + 1 < GetNetworkClientInfoPoolSize()) {
 
				/* Skip inactive clients */
 
				NetworkClientInfo *ci;
 
				FOR_ALL_CLIENT_INFOS_FROM(ci, *item + 1) break;
 
				if (ci != NULL) {
 
					*item = ci->index;
 
					return ci->client_name;
 
				}
 
			}
 
			*item = MAX_CLIENT_SLOTS;
 
		}
0 comments (0 inline, 0 general)