libsepol: Use spaceship comparison operator when comparing ibpkeys
PATCH 1/1 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.
--- libsepol/src/kernel_to_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
libsepol/src/kernel_to_common.c +2 -1
@@ -585,7 +585,8 @@ static int ibpkey_data_cmp(const void *a, const void *b)struct ocontext *const *aa = a;struct ocontext *const *bb = b; - rc = (*aa)->u.ibpkey.subnet_prefix - (*bb)->u.ibpkey.subnet_prefix; + rc =spaceship_cmp ((*aa)->u.ibpkey.subnet_prefix, + (*bb)->u.ibpkey.subnet_prefix);if (rc)return rc;
Signature · 1 line
2.55.0
Quoted 10 lines · James Carter
The comparsion function for ibpkeys in
kernel_to_commonsubtracts thesubnet_prefixesof 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_prefxesto avoid any issues.Signed-off-by James Carter <[email protected]>
Stephen Smalley
maintainerQuoted 8 lines · Stephen Smalley
Quoted 6 lines · James Carter
The comparsion function for ibpkeys in
kernel_to_commonsubtracts thesubnet_prefixesof 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.
Quoted 6 lines
Quoted 4 lines
Use the spaceship comparison operator to compare the
subnet_prefxesto avoid any issues.Signed-off-by James Carter <[email protected]>Acked-by Stephen Smalley <[email protected]>
Thanks, merged.