Package: rdate
Version: 1:1.1.3-2
Severity: normal

It is not possible to connect to an NTP server over IPv6.

$ rdate -v -n -p -6 eu.ntp.sixxs.net
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Failed to connect to server: Invalid argument
rdate: Unable to get a reasonable time estimate

-- System Information:
Debian Release: 5.0
  APT prefers unstable
  APT policy: (900, 'unstable'), (500, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-1-686 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=pl_PL.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages rdate depends on:
ii  libc6                         2.7-18     GNU C Library: Shared libraries

rdate recommends no packages.

rdate suggests no packages.

-- no debconf information

--
Jakub Wilk
diff --git a/src/ntp.c b/src/ntp.c
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -91,10 +91,6 @@
 #define MILLION_L    1000000l		/* For conversion to/from timeval */
 #define MILLION_D       1.0e6		/* Must be equal to MILLION_L */
 
-#ifdef __GLIBC__
-#define SA_LEN(x)	sizeof(*x)
-#endif
-
 struct ntp_data {
 	u_char		status;
 	u_char		version;
@@ -111,7 +107,7 @@
 };
 
 void	ntp_client(const char *, int, struct timeval *, struct timeval *, int, int, int);
-int	sync_ntp(int, const struct sockaddr *, double *, double *, int);
+int	sync_ntp(int, const struct sockaddr *, socklen_t, double *, double *, int);
 int	write_packet(int, struct ntp_data *);
 int	read_packet(int, struct ntp_data *, double *, double *);
 void	unpack_ntp(struct ntp_data *, u_char *);
@@ -155,7 +151,8 @@
 			((struct sockaddr_in*)res->ai_addr)->sin_port = htons(port);
 		}
 
-		ret = sync_ntp(s, res->ai_addr, &offset, &error, verbose);
+		ret = sync_ntp(s, res->ai_addr, res->ai_addrlen, &offset,
+			&error, verbose);
 		if (ret < 0) {
 #ifdef DEBUG
 			fprintf(stderr, "try the next address\n");
@@ -181,8 +178,8 @@
 }
 
 int
-sync_ntp(int fd, const struct sockaddr *peer, double *offset, double *error,
-    int verbose)
+sync_ntp(int fd, const struct sockaddr *peer, socklen_t addrlen,
+    double *offset, double *error, int verbose)
 {
 	int attempts = 0, accepts = 0, rejects = 0;
 	int delay = MAX_DELAY, ret;
@@ -195,7 +192,7 @@
 	*offset = 0.0;
 	*error = NTP_INSANITY;
 
-	if (connect(fd, peer, SA_LEN(peer)) < 0) {
+	if (connect(fd, peer, addrlen) < 0) {
 		warn("Failed to connect to server");
 		return (-1);
 	}

Reply via email to