Use the math function floor instead of casting to an int to truncate OS scan

match percentages. Casting to an int rounds (0.98 * 100) to 97 on some
architectures.
This commit is contained in:
david 2008-11-20 17:03:11 +00:00
parent b87ef8aabd
commit 47c268568d
2 changed files with 8 additions and 4 deletions

View file

@ -114,6 +114,8 @@
#include "Target.h"
#include "utils.h"
#include <math.h>
#include <string>
#include <vector>
#include <list>
@ -1528,7 +1530,7 @@ static void printosclassificationoutput(const struct OS_Classification_Results *
if (familyno > 0) log_write(LOG_PLAIN, ", ");
log_write(LOG_PLAIN, "%s", fullfamily[familyno]);
if (*familygenerations[familyno]) log_write(LOG_PLAIN, " %s", familygenerations[familyno]);
if (familyaccuracy[familyno] < 1.0) log_write(LOG_PLAIN, " (%d%%)", (int) (familyaccuracy[familyno] * 100));
if (familyaccuracy[familyno] < 1.0) log_write(LOG_PLAIN, " (%.f%%)", floor(familyaccuracy[familyno] * 100));
}
log_write(LOG_PLAIN, "\n");
}
@ -1656,9 +1658,10 @@ void printosscanoutput(Target *currenths) {
free(p);
}
log_write(LOG_PLAIN,"Aggressive OS guesses: %s (%d%%)", FPR->prints[0]->OS_name, (int) (FPR->accuracy[0] * 100));
log_write(LOG_PLAIN,"Aggressive OS guesses: %s (%.f%%)", FPR->prints[0]->OS_name, floor(FPR->accuracy[0] * 100));
for (i = 1; i < 10 && FPR->num_matches > i && FPR->accuracy[i] > FPR->accuracy[0] - 0.10; i++)
log_write(LOG_PLAIN,", %s (%d%%)", FPR->prints[i]->OS_name, (int) (FPR->accuracy[i] * 100));
log_write(LOG_PLAIN,", %s (%.f%%)", FPR->prints[i]->OS_name, floor(FPR->accuracy[i] * 100));
log_write(LOG_PLAIN, "\n");
}

View file

@ -113,6 +113,7 @@
#include "Target.h"
#include "targets.h"
#include "utils.h"
#include <math.h>
#include <list>
#include <map>
@ -5355,7 +5356,7 @@ void pos_scan(Target *target, u16 *portarray, int numports, stype scantype) {
tries++;
if (o.debugging) {
log_write(LOG_STDOUT, "Finished round #%d. Current stats: numqueries_ideal: %d; min_width: %d; max_width: %d; packet_incr: %d; senddelay: %dus; fallback: %d%%\n", tries, (int) ss.numqueries_ideal, ss.min_width, ss.max_width, ss.packet_incr, senddelay, (int) (100 * ss.fallback_percent));
log_write(LOG_STDOUT, "Finished round #%d. Current stats: numqueries_ideal: %d; min_width: %d; max_width: %d; packet_incr: %d; senddelay: %dus; fallback: %.f%%\n", tries, (int) ss.numqueries_ideal, ss.min_width, ss.max_width, ss.packet_incr, senddelay, floor(100 * ss.fallback_percent));
}
ss.numqueries_ideal = ss.initial_packet_width;