Re: [PATCH] Fix for ipv6 address merge error reported on argus mailing list.
Carter Bullard <[email protected]> Sat, 30 Jun 2018 09:34:10 -0400
| Newsgroups | gmane.network.argus |
|---|---|
| Message-ID | <[email protected]> |
Not sure if you got this … Just a resend. Carter > On Jun 29, 2018, at 11:56 AM, Carter Bullard <[email protected]> wrote: > > IPv6 address merging generated short or mangled results. > Fixed issue where not looking at right part of the address for comparison. > Needed to ntohl the 32-bit chunk that was being compared. > > (cherry picked from commit 97b17fb3da6cde58f1d2386315fb9e746dd76c85) > --- > common/argus_client.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/common/argus_client.c b/common/argus_client.c > index 013fea6e..7603f33b 100644 > --- a/common/argus_client.c > +++ b/common/argus_client.c > @@ -6946,15 +6946,17 @@ ArgusMergeAddress(unsigned int *a1, unsigned int *a2, int type, int dir, unsigne > for (z = 0; z < 4; z++) { > if (a1[z] != a2[z]) { > unsigned int i = 32, value = 0, ind; > + unsigned int na1 = ntohl(a1[z]); > + unsigned int na2 = ntohl(a2[z]); > ind = 0x80000000; > > - while (ind && ((*a1 & ind) == (*a2 & ind)) && (i > (32 - *masklen))) { > - value |= (*a1 & ind); > - ind >>= 1; > + while (ind && ((na1 & ind) == (na2 & ind))) { > + value |= (na1 & ind); > + ind >>= 1; > i--; > - } > + } > *masklen = (z * 32) + (32 - i); > - a1[z] = value; > + a1[z] = htonl(value); > while ((z + 1) < 4) { > a1[z + 1] = 0; > z++; > -- > 2.17.1 > >