Package: guessnet
Version: 0.42-1
Severity: important
Tags: patch
I don't know why, but sometimes guessnet receives an ARP answer twice or
even more often. As guessnet removes the signature of the first ARP
answer from all candidates the next identical ARP answer will remove
all remaining candidates, and so guessnet fails.
I patched it, so that guessnet saves all received signatures in a set
and keeps all candidates, that have the incoming ARP answer in that set.
Greetings,
Alexander Motzkau
-- System Information:
Debian Release: 4.0
APT prefers stable
APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.21
Locale: LANG=de_DE.utf8, LC_CTYPE=de_DE.utf8 (charmap=UTF-8) (ignored: LC_ALL
set to de_DE.utf8)
Versions of packages guessnet depends on:
ii libc6 2.3.6.ds1-13etch2 GNU C Library: Shared libraries
ii libgcc1 1:4.1.1-21 GCC support library
ii libnet1 1.1.2.1-2 library for the construction and h
ii libpcap0.7 0.7.2-7 System interface for user-level pa
ii libstdc++6 4.1.1-21 The GNU Standard C++ Library v3
guessnet recommends no packages.
-- no debconf information
--- guessnet-0.42.orig/src/ScanBag.h
+++ guessnet-0.42/src/ScanBag.h
@@ -6,10 +6,11 @@
#include <set>
#include <vector>
#include <string>
+#include <utility>
#include "Parser.h"
-class ScanBag : protected std::map<std::string, std::set<std::string> >
+class ScanBag : protected std::map<std::string, std::pair<std::set<std::string>, std::set<std::string> > >
{
std::list<const Scan*> scans;
std::string defaultProfile;
@@ -33,7 +34,7 @@
/// Remove all items from this ScanBag
void clear() throw ()
{
- std::map<std::string, std::set<std::string> >::clear();
+ std::map<std::string, std::pair<std::set<std::string>, std::set<std::string> > >::clear();
scans.clear();
}
--- guessnet-0.42.orig/src/ScanBag.cc
+++ guessnet-0.42/src/ScanBag.cc
@@ -1,4 +1,5 @@
#include "ScanBag.h"
+#include "Environment.h"
#include <iostream>
using namespace std;
@@ -16,12 +17,13 @@
} else {
set<string> v;
v.insert(scan->signature());
- insert(pair<string, set<string> >(scan->name(), v));
+ insert(pair<string, pair<set<string>, set<string> > >(scan->name(),
+ pair<set<string>, set<string> >(v, set<string>())));
}
}
else
{
- i->second.insert(scan->signature());
+ i->second.first.insert(scan->signature());
}
scans.push_back(scan);
@@ -41,8 +43,18 @@
string sig = scan->signature();
for (iterator i = begin(); i != end(); )
{
- set<string>::iterator j = i->second.find(sig);
- if (j == i->second.end())
+ set<string>::iterator j = i->second.first.find(sig);
+ if (j != i->second.first.end())
+ {
+ // This candidate has a scan with the signature
+ // so remove the matching scan
+ i->second.second.insert(sig);
+ i->second.first.erase(j);
+
+ cands_left.push_back(i->first);
+ i++;
+ }
+ else if(i->second.second.find(sig) == i->second.second.end())
{
// This candidate has no scan with the signature
// so remove the candidate
@@ -53,9 +65,6 @@
}
else
{
- // This candidate has a scan with the signature
- // so remove the matching scan
- i->second.erase(j);
cands_left.push_back(i->first);
i++;
}
@@ -69,9 +78,9 @@
int count = -1;
for (const_iterator i = begin(); i != end(); i++)
{
- if (count == -1 || (signed)i->second.size() < count)
+ if (count == -1 || (signed)i->second.first.size() < count)
{
- count = i->second.size();
+ count = i->second.first.size();
cand = i->first;
}
}
@@ -88,8 +97,8 @@
for (const_iterator i = begin(); i != end(); i++)
{
cout << i->first << ": ";
- for (set<string>::const_iterator j = i->second.begin(); j != i->second.end(); j++)
- if (j == i->second.begin())
+ for (set<string>::const_iterator j = i->second.first.begin(); j != i->second.first.end(); j++)
+ if (j == i->second.first.begin())
cout << *j;
else
cout << ", ", *j;