Skip to content

Commit

Permalink
Explicitly check availability of capability in current kernel before …
Browse files Browse the repository at this point in the history
…printing its value. Accessing a capability that is not valid can never lead to a crash, however, it is also no a menaingful thing to do so we don't do it.

Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Mar 17, 2019
1 parent 73cbb91 commit 4a15b93
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions capabilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ bool check_capabilities()
for(unsigned int i = 0u; i < (sizeof(capabilityIntegers)/sizeof(const int)); i++)
{
unsigned int capid = capabilityIntegers[i];

// Check if capability is valid for the current kernel
// If not, exit loop early
if(!cap_valid(capid))
break;

logg("DEBUG: Capability %-24s (%02u) = %s%s%s",
capabilityNames[capid],
capid,
Expand Down

0 comments on commit 4a15b93

Please sign in to comment.