On Fri, Oct 25, 2013 at 01:31:45PM +0200, Jérémie Courrèges-Anglas wrote:
> 
> Hi,
> 
> I don't think this happened before the time_t bump, I'm not sure whether
> it happens only on 32 bits archs (I only have this at hand), but nmap is
> unusable for me.  It fails on an assert call before printing any result.
> 
> Now, looking at the code, there's something fishy involving struct
> timeval, doubles and weird fp arithmetic.  No idea why that code doesn't
> use only struct timeval, but anyway...
> 
> I've launched nmap with debug fprintfs, and the difference between the
> two double values is always so small in the failing case that I like to
> think about a fp math error more than about a real, logic error.
> 
> Can you reproduce the failing assert on 64 bits archs?  If so, would the
> diff below be ok?
> 
This assert is 32bit only, this diff will fix the problem.
 Cheers
  Giovanni
Index: Makefile
===================================================================
RCS file: /cvs/ports/net/nmap/Makefile,v
retrieving revision 1.107
diff -u -p -u -p -r1.107 Makefile
--- Makefile    10 May 2013 12:27:45 -0000      1.107
+++ Makefile    24 Oct 2013 17:20:48 -0000
@@ -6,7 +6,7 @@ COMMENT-zenmap= graphical frontend for n
 MODPY_EGG_VERSION=     6.25
 DISTNAME=              nmap-${MODPY_EGG_VERSION}
 PKGNAME-main=          ${DISTNAME}
-REVISION-main=         0
+REVISION-main=         1
 PKGNAME-zenmap=                nmap-zenmap-${MODPY_EGG_VERSION}
 
 CATEGORIES=    net security
Index: patches/patch-osscan2_cc
===================================================================
RCS file: patches/patch-osscan2_cc
diff -N patches/patch-osscan2_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-osscan2_cc    24 Oct 2013 17:20:48 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+--- osscan2.cc.orig    Thu Oct 24 16:11:46 2013
++++ osscan2.cc Thu Oct 24 16:12:32 2013
+@@ -2407,8 +2407,8 @@ void HostOsScan::makeTSeqFP(HostOsScanStats *hss) {
+     if (lastboot != 0.0 && (hss->seq_send_times[0].tv_sec - lastboot > 
63072000)) {
+       /* Up 2 years?  Perhaps, but they're probably lying. */
+       if (o.debugging) {
+-        log_write(LOG_STDOUT, "Ignoring claimed %s uptime of %lu days\n",
+-        hss->target->targetipstr(), (hss->seq_send_times[0].tv_sec - 
hss->si.lastboot) / 86400);
++        log_write(LOG_STDOUT, "Ignoring claimed %s uptime of %lu days\n",
++        hss->target->targetipstr(), ((long unsigned 
int)hss->seq_send_times[0].tv_sec - hss->si.lastboot) / 86400);
+       }
+       lastboot = 0;
+     }
Index: patches/patch-output_cc
===================================================================
RCS file: /cvs/ports/net/nmap/patches/patch-output_cc,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 patch-output_cc
--- patches/patch-output_cc     19 Dec 2012 17:12:11 -0000      1.2
+++ patches/patch-output_cc     24 Oct 2013 17:20:48 -0000
@@ -1,6 +1,15 @@
 $OpenBSD: patch-output_cc,v 1.2 2012/12/19 17:12:11 giovanni Exp $
 --- output.cc.orig     Thu Nov 29 04:19:52 2012
-+++ output.cc  Fri Nov 30 12:41:48 2012
++++ output.cc  Thu Oct 24 16:13:24 2013
+@@ -1941,7 +1941,7 @@ void printosscanoutput(Target *currenths) {
+                 (double) (tv.tv_sec - currenths->seq.lastboot) / 86400,
+                 tmbuf);
+     xml_open_start_tag("uptime");
+-    xml_attribute("seconds", "%li", tv.tv_sec - currenths->seq.lastboot);
++    xml_attribute("seconds", "%lu", (long unsigned int)tv.tv_sec - 
currenths->seq.lastboot);
+     xml_attribute("lastboot", "%s", tmbuf);
+     xml_close_empty_tag();
+     xml_newline();
 @@ -2411,7 +2411,7 @@ void printStatusMessage() {
    // Pre-computations
    struct timeval tv;
Index: patches/patch-scan-engine_cc
===================================================================
RCS file: /cvs/ports/net/nmap/patches/patch-scan-engine_cc,v
retrieving revision 1.5
diff -u -p -u -p -r1.5 patch-scan-engine_cc
--- patches/patch-scan-engine_cc        19 Dec 2012 17:12:11 -0000      1.5
+++ patches/patch-scan-engine_cc        24 Oct 2013 17:20:48 -0000
@@ -1,5 +1,5 @@
 --- scan_engine.cc.orig        Wed Oct 31 18:00:55 2012
-+++ scan_engine.cc     Fri Nov 30 12:43:04 2012
++++ scan_engine.cc     Thu Oct 24 16:14:00 2013
 @@ -5540,13 +5540,13 @@ static void begin_sniffer(UltraScanInfo *USI, std::vec
      if (doIndividual) {
        pcap_filter = "dst host ";
@@ -16,3 +16,13 @@
      }
    } else {
      assert(0);
+@@ -5937,7 +5937,7 @@ void bounce_scan(Target *target, u16 *portarray, int n
+   }
+ 
+   if (o.debugging || o.verbose)
+-    log_write(LOG_STDOUT, "Scanned %d ports in %ld seconds via the Bounce 
scan.\n",
+-              numports, (long) time(NULL) - starttime);
++    log_write(LOG_STDOUT, "Scanned %d ports in %lu seconds via the Bounce 
scan.\n",
++              numports, (long unsigned int) time(NULL) - starttime);
+   return;
+ }
Index: patches/patch-timing_cc
===================================================================
RCS file: patches/patch-timing_cc
diff -N patches/patch-timing_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-timing_cc     24 Oct 2013 17:20:48 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+--- timing.cc.orig     Thu Oct 17 09:02:45 2013
++++ timing.cc  Thu Oct 17 09:03:10 2013
+@@ -358,9 +358,9 @@ void RateMeter::stop(const struct timeval *now) {
+    now. If now is NULL, get the current time with gettimeofday. */
+ void RateMeter::update(double amount, const struct timeval *now) {
+   struct timeval tv;
+-  double diff;
+-  double interval;
+-  double count;
++  time_t diff;
++  time_t interval;
++  time_t count;
+ 
+   assert(isSet(&start_tv));
+   assert(!isSet(&stop_tv));

Reply via email to