Author: amunger Date: Wed Nov 5 13:19:56 2008 New Revision: 37215
URL: http://svn.reactos.org/svn/reactos?rev=37215&view=rev Log: Fix a fencepost bug. Correct a glaring typo. Make code less ugly.
Modified: trunk/reactos/base/services/dhcp/util.c
Modified: trunk/reactos/base/services/dhcp/util.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/util.c?r... ============================================================================== --- trunk/reactos/base/services/dhcp/util.c [iso-8859-1] (original) +++ trunk/reactos/base/services/dhcp/util.c [iso-8859-1] Wed Nov 5 13:19:56 2008 @@ -97,7 +97,7 @@ void *dmalloc( int size, char *name ) { return malloc( size ); }
int read_client_conf(void) { - /* What a strage dance */ + /* What a strange dance */ struct client_config *config; char ComputerName [MAX_COMPUTERNAME_LENGTH + 1]; LPSTR lpCompName; @@ -113,14 +113,16 @@
GetComputerName(ComputerName, & ComputerNameSize); + debug("Hostname: %s, length: %lu", + ComputerName, ComputerNameSize); /* This never gets freed since it's only called once */ lpCompName = - HeapAlloc(GetProcessHeap(), 0, strlen(ComputerName) + 1); + HeapAlloc(GetProcessHeap(), 0, ComputerNameSize + 1); if (lpCompName !=NULL) { - GetComputerName(lpCompName, & ComputerNameSize); + memcpy(lpCompName, ComputerName, ComputerNameSize + 1); /* Send our hostname, some dhcpds use this to update DNS */ config->send_options[DHO_HOST_NAME].data = (u_int8_t*)strlwr(lpCompName); - config->send_options[DHO_HOST_NAME].len = strlen(ComputerName); + config->send_options[DHO_HOST_NAME].len = ComputerNameSize; debug("Hostname: %s, length: %d", config->send_options[DHO_HOST_NAME].data, config->send_options[DHO_HOST_NAME].len);