Skip to content

Commit 2ffdb3e

Browse files
jwcart2stephensmalley
authored andcommitted
libsepol: Use spaceship comparison operator when comparing ibpkeys
The comparsion function for ibpkeys in kernel_to_common subtracts the subnet_prefixes of the two ibpkeys which are unsigned 64-bit values and stores the result in an int which might not be able to contain the result. Use the spaceship comparison operator to compare the subnet_prefxes to avoid any issues. Signed-off-by: James Carter <jwcart2@gmail.com> Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
1 parent 6efa4c6 commit 2ffdb3e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

libsepol/src/kernel_to_common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,8 @@ static int ibpkey_data_cmp(const void *a, const void *b)
585585
struct ocontext *const *aa = a;
586586
struct ocontext *const *bb = b;
587587

588-
rc = (*aa)->u.ibpkey.subnet_prefix - (*bb)->u.ibpkey.subnet_prefix;
588+
rc = spaceship_cmp((*aa)->u.ibpkey.subnet_prefix,
589+
(*bb)->u.ibpkey.subnet_prefix);
589590
if (rc)
590591
return rc;
591592

0 commit comments

Comments
 (0)