Author: cgutman
Date: Thu Aug 27 23:31:49 2009
New Revision: 42958
URL:
http://svn.reactos.org/svn/reactos?rev=42958&view=rev
Log:
- Check that we got a valid socket before trying to bind
Modified:
trunk/reactos/base/services/dhcp/adapter.c
Modified: trunk/reactos/base/services/dhcp/adapter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/adapter…
==============================================================================
--- trunk/reactos/base/services/dhcp/adapter.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/dhcp/adapter.c [iso-8859-1] Thu Aug 27 23:31:49 2009
@@ -299,13 +299,18 @@
Adapter->DhclientInfo.rfdesc =
Adapter->DhclientInfo.wfdesc =
socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
- Adapter->ListenAddr.sin_family = AF_INET;
- Adapter->ListenAddr.sin_port = htons(LOCAL_PORT);
- Adapter->BindStatus =
- (bind( Adapter->DhclientInfo.rfdesc,
- (struct sockaddr *)&Adapter->ListenAddr,
- sizeof(Adapter->ListenAddr) ) == 0) ?
- 0 : WSAGetLastError();
+
+ if (DhcpSocket != INVALID_SOCKET) {
+ Adapter->ListenAddr.sin_family = AF_INET;
+ Adapter->ListenAddr.sin_port = htons(LOCAL_PORT);
+ Adapter->BindStatus =
+ (bind( Adapter->DhclientInfo.rfdesc,
+ (struct sockaddr *)&Adapter->ListenAddr,
+ sizeof(Adapter->ListenAddr) ) == 0) ?
+ 0 : WSAGetLastError();
+ } else {
+ error("socket() failed: %d\n", WSAGetLastError());
+ }
} else {
Adapter->DhclientInfo.rfdesc =
Adapter->DhclientInfo.wfdesc = DhcpSocket;