Fix a fencepost bug.
authorAndrew Munger <waxdragon@gmail.com>
Wed, 5 Nov 2008 19:19:56 +0000 (19:19 +0000)
committerAndrew Munger <waxdragon@gmail.com>
Wed, 5 Nov 2008 19:19:56 +0000 (19:19 +0000)
Correct a glaring typo.
Make code less ugly.

svn path=/trunk/; revision=37215

reactos/base/services/dhcp/util.c

index 3075fb8..2dd7623 100644 (file)
@@ -97,7 +97,7 @@ int addr_eq( struct iaddr a, struct iaddr b ) {
 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 @@ int read_client_conf(void) {
 
 
        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);