]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Fix IP addressing in chronyc
authorThomas Zajic <zlatko@zlatko.fdns.net>
Tue, 29 Jul 2008 22:35:42 +0000 (23:35 +0100)
committerRichard P. Curnow <rc@rc0.org.uk>
Tue, 29 Jul 2008 22:35:42 +0000 (23:35 +0100)
Thomas wrote:
I found a bug in the chrony client (chronyc) that affects its ability to talk
to remote hosts over the control port (323/udp).

For example, running "chronyc -h 192.168.1.3 sources -v" would just sit there
and hang, and eventually timeout. I found out with tcpdump that chronyc
actually tries to connect to 255.168.1.3 instead of 192.168.1.3.

client.c

index 85d6e845f30a4a80c06b7a1155542fb13226b175..66f297fb0200c5bcd0fc24a32d57881ebcec227d 100644 (file)
--- a/client.c
+++ b/client.c
@@ -163,10 +163,10 @@ get_address(const char *hostname)
     exit(1);
   } else {
     address0 = host->h_addr_list[0];
-    result = ((((unsigned long) address0[0]) << 24) |
-              (((unsigned long) address0[1]) << 16) |
-              (((unsigned long) address0[2]) <<  8) |
-              (((unsigned long) address0[3])));
+    result = ((((unsigned long) address0[0] & 0xff) << 24) |
+              (((unsigned long) address0[1] & 0xff) << 16) |
+              (((unsigned long) address0[2] & 0xff) <<  8) |
+              (((unsigned long) address0[3] & 0xff)));
   }
 
   return result;