Package: chrony
Version: 1.20-8c0.mrvn.1
Followup-For: Bug #348412

Hi,

attached is a patchlet to make the "sources" command of chrony output
properly signed numbers. The chronyd code (see e.g. ntp.h) properly
uses int32_t and friends to get the right number of bits per datatype
while client.c just uses short, int, long. But long will be 64 bit or
32 bit depending on the cpu.

This makes chronyc display the wrong values while chronyd works
perfectly. The patch just fixes the sources command but I'm certain
there are more errors of the same kind.

I suggest going through the source and replacing all occurances of
long with int32_t. This will make 64bit cpus use the same bits per
type as 32bit cpus. Signed/Unsigned conversion and sign extensions
should then be the same across the board.

MfG
        Goswin


-- System Information:
Debian Release: 3.1
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.16-rc4-xen
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages chrony depends on:
ii  libc6                       2.3.2.ds1-22 GNU C Library: Shared libraries an
ii  libncurses5                 5.4-4        Shared libraries for terminal hand
ii  libreadline5                5.0-10       GNU readline and history libraries

-- no debconf information
diff -u chrony-1.20/debian/changelog chrony-1.20/debian/changelog
--- chrony-1.20/debian/changelog
+++ chrony-1.20/debian/changelog
@@ -1,3 +1,9 @@
+chrony (1.20-8c0.mrvn.1) unstable; urgency=low
+
+  * client.c: process_cmd_sources(): change types (u)int32_t and (u)int16_t
+
+ -- Goswin von Brederlow <[EMAIL PROTECTED]>  Tue,  4 Apr 2006 05:33:34 +0200
+
 chrony (1.20-8) unstable; urgency=high
 
   * Added test for /usr/bin/mail in postinst.
diff -u chrony-1.20/debian/control chrony-1.20/debian/control
--- chrony-1.20/debian/control
+++ chrony-1.20/debian/control
@@ -3,7 +3,7 @@
 Priority: extra
 Maintainer: John Hasler <[EMAIL PROTECTED]>
 Standards-Version: 3.5.8.0
-Build-Depends: debhelper, libreadline4-dev, texinfo, bison
+Build-Depends: debhelper, libreadline5-dev, texinfo, bison
 
 Package: chrony
 Architecture: any
only in patch2:
unchanged:
--- chrony-1.20.orig/client.c
+++ chrony-1.20/client.c
@@ -45,6 +45,12 @@
 #include <readline/history.h>
 #endif
 
+#ifdef HAS_STDINT_H
+#include <stdint.h>
+#elif defined(HAS_INTTYPES_H)
+#include <inttypes.h>
+#endif
+
 /* ================================================== */
 
 static int sock_fd;
@@ -1383,16 +1389,16 @@
   int n_sources, i;
   int verbose = 0;
 
-  long orig_latest_meas, latest_meas, est_offset;
-  unsigned long ip_addr;
-  unsigned long latest_meas_err, est_offset_err;
-  unsigned long latest_meas_ago;
-  unsigned short poll, stratum;
-  unsigned short state, mode;
+  int32_t orig_latest_meas, latest_meas, est_offset;
+  uint32_t ip_addr;
+  uint32_t latest_meas_err, est_offset_err;
+  uint32_t latest_meas_ago;
+  uint16_t poll, stratum;
+  uint16_t state, mode;
   double resid_freq, resid_skew;
   const char *dns_lookup;
   char hostname_buf[32];
-  unsigned short status;
+  uint16_t status;
 
   /* Check whether to output verbose headers */
   verbose = check_for_verbose_flag(line);

Reply via email to