test: use cap_last_cap() for max supported cap number, not capability_list_length()

This test assumes capability_list_length() is an invalid cap number,
but that isn't true if the running kernel supports more caps than we were
compiled with, which results in the test failing.

Instead use cap_last_cap() + 1.

If cap_last_cap() is 63, there are no more 'invalid' cap numbers to test with,
so the invalid cap number test part is skipped.
This commit is contained in:
Dan Streetman
2020-11-25 15:22:24 -05:00
committed by Zbigniew Jędrzejewski-Szmek
parent 9684a01ce4
commit ebc815cd1c
2 changed files with 36 additions and 29 deletions

View File

@@ -50,6 +50,9 @@ int capability_from_name(const char *name) {
return sc->id;
}
/* This is the number of capability names we are *compiled* with.
* For the max capability number of the currently-running kernel,
* use cap_last_cap(). */
int capability_list_length(void) {
return (int) ELEMENTSOF(capability_names);
}