[PATCH v2] Fix a couple of obvious 2-byte ASn limits
Timo Koehler
tkoehler at acm.org
Tue Jun 22 11:01:54 UTC 2010
Faidon Liambotis wrote:
> re2dfa's MAX_AS was set to 65535, thus failing on expressions
> containing 4-byte ASes, e.g.
> import: from AS197121 accept
> AS197121 AND <^AS197121>;
>
> Additionally, RPSL's RANGE_TOP (which is used as MAX_AS in regexp.cc)
> was set to 65535. I couldn't pinpoint an exact problem, but smells like
> a bug, hence adjust that to 2^32 too.
correct. I vaguely remember that someone already published a rudimentary
patch for 4-byte ASN support back in 2008.
At that time I also wrote a patch for this, based on 4.8.5, including
your changes and some more but never published my code because of some
copyright problems at that time.
>
> Finally, RE_INVALID_AS was an int and set to RANGE_TOP + 1. Make it an
> unsigned int and set it to 0, since it's only used for comparison in a
> couple of assert() statements.
>
Not sure which code base you work but in 4.8.5 I wrote this:
// RE_INVALID_AS is used as default peerAS. The valid_peer_as
// flag is used to indicate a non-default peerAS.
+const unsigned int RE_INVALID_AS = RANGE_TOP;
And it is used in src/re2dfa/regexp_nf.hh:
rd_fm* dfa(ASt peerAS = RE_INVALID_AS);
> (v2: use a "u" suffix to denote that the number is unsigned, eliminating
> a GCC warning in some versions)
> ---
> src/re2dfa/re2dfa.h | 2 +-
> src/re2dfa/regexp_nf.hh | 2 +-
> src/rpsl/rangelist.hh | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/re2dfa/re2dfa.h b/src/re2dfa/re2dfa.h
> index e0cfd38..1c4a58c 100644
> --- a/src/re2dfa/re2dfa.h
> +++ b/src/re2dfa/re2dfa.h
> @@ -48,7 +48,7 @@
>
> #include "config.h"
>
> -#define MAX_AS 65535
> +#define MAX_AS 4294967295u
>
> /*
> * The following is a compile time limit on the number of NFA states
> diff --git a/src/re2dfa/regexp_nf.hh b/src/re2dfa/regexp_nf.hh
> index e1f7edf..2a7cdab 100644
> --- a/src/re2dfa/regexp_nf.hh
> +++ b/src/re2dfa/regexp_nf.hh
> @@ -55,7 +55,7 @@
> #include "rpsl/rpsl_item.hh"
>
> typedef unsigned int ASt;
> -const int RE_INVALID_AS = RANGE_TOP + 1;
> +const unsigned int RE_INVALID_AS = 0;
>
> extern "C" {
> #include "re2dfa.h"
> diff --git a/src/rpsl/rangelist.hh b/src/rpsl/rangelist.hh
> index 5e3f9d8..0ca4b90 100644
> --- a/src/rpsl/rangelist.hh
> +++ b/src/rpsl/rangelist.hh
> @@ -52,7 +52,7 @@
> #include <iostream>
> #include "List.hh"
>
> -#define RANGE_TOP 65535
> +#define RANGE_TOP 4294967295u
>
> class RangeList {
> friend class regexp_nf;
rangelist.hh I also fixed a number of class constructors, like:
- Range(int l, int h) : low(l), high(h) {}
+ Range(unsigned int l, unsigned int h) : low(l), high(h) {}
Let me know in case you need my asn32 code to compare against yours.
Timo
More information about the irrtoolset
mailing list