csv: time_t and printf()

Bug #1180403 reported by Yakovetsky VS on 2013-05-15
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

printf() and time_t:
on NetBSD6/i386 long is 32 bits, time_t is 64 bits.

% uname -srm
NetBSD 6.0.1 i386

% ./mtr -v
mtr 0.84+git:9df5282f

% ./mtr -tC -c1 localhost
zsh: segmentation fault (core dumped) ./mtr -tC -c1 localhost

% gdb mtr
GNU gdb (GDB) 7.3.1
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486--netbsdelf".
For bug reporting instructions, please see:
Reading symbols from /usr/home/yvs/src/mtr-git_9df5282f/mtr...done.
(gdb) set args -tC -c1 localhost
(gdb) run
Starting program: /usr/home/yvs/src/mtr-git_9df5282f/mtr -tC -c1 localhost

Program received signal SIGSEGV, Segmentation fault.
[Switching to LWP 1]
0xbb158daa in __vfprintf_unlocked () from /usr/lib/
(gdb) bt
#0 0xbb158daa in __vfprintf_unlocked () from /usr/lib/
#1 0xbb159eef in vfprintf () from /usr/lib/
#2 0xbb154efa in printf () from /usr/lib/
#3 0x0805539d in csv_close (now=1368624897) at report.c:349
#4 0x0804f460 in main (argc=4, argv=0xbfbfec40) at mtr.c:686
(gdb) list report.c:349,350
349 printf("MTR.%s;%lu;%s;%s;%d;%s;%d", MTR_VERSION, now, "OK", Hostname,
350 at+1, name, last);
(gdb) print sizeof(time_t)
$1 = 8
(gdb) print sizeof(long)
$2 = 4

--- report.c.orig 2013-05-15 13:24:32.000000000 +0300
+++ report.c 2013-05-15 14:36:29.000000000 +0300
@@ -340,15 +340,16 @@
     snprint_addr(name, sizeof(name), addr);

     int last = net_last(at);
+#ifndef NO_IPINFO
     if(!ipinfo_no) {
       char* fmtinfo = fmt_ipinfo(addr);
       if (fmtinfo != NULL) fmtinfo = trim(fmtinfo);
- printf("MTR.%s;%lu;%s;%s;%d;%s;%s;%d", MTR_VERSION, now, "OK", Hostname,
+ printf("MTR.%s;%lld;%s;%s;%d;%s;%s;%d", MTR_VERSION, (long long)now, "OK", Hostname,
              at+1, name, fmtinfo, last);
- } else {
- printf("MTR.%s;%lu;%s;%s;%d;%s;%d", MTR_VERSION, now, "OK", Hostname,
+ } else
+ printf("MTR.%s;%lld;%s;%s;%d;%s;%d", MTR_VERSION, (long long)now, "OK", Hostname,
              at+1, name, last);
- }

     for( i=0; i<MAXFLD; i++ ) {
       j = fld_index[fld_active[j]];

Yakovetsky VS (vsyakovetsky) wrote :
Changed in mtr:
status: New → Fix Committed
Yakovetsky VS (vsyakovetsky) wrote :

report.c@57f2d65 "fix for NetBSD: 64bit time_t -- Thomas Klausner"
report.c@25a2456 "glib dependency fixes."
report.c@92f3c2a "added typo fix."

Changed in mtr:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers