MDEV-19669 - fix matching CIDR address for proxy protocol.

Prior to this fix, when matching addresses using mask,
extra bits could be used for  comparison, e.g to
match with "a.b.c.d/24" , 27 bits were compared rather than 24.

The patch fixes the calculation.
This commit is contained in:
Vladislav Vaintroub 2019-11-27 20:44:14 +01:00
parent 3fc1f6260f
commit 584ffa02f1

View File

@ -470,7 +470,7 @@ static int compare_bits(const void *s1, const void *s2, int bit_count)
int byte_count= bit_count / 8;
if (byte_count && (result= memcmp(s1, s2, byte_count)))
return result;
int rem= byte_count % 8;
int rem= bit_count % 8;
if (rem)
{
// compare remaining bits i.e partial bytes.