mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 01:57:43 +00:00
Fix infinite loop in chfa.cc:weld_file_to_policy
This is simple enough to fix even if weld_file_to_policy isn't used in practice with the compat layer that uses it being a target for deletion Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
This commit is contained in:
parent
5b391a5a4f
commit
88719dbb7b
@ -25,6 +25,8 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -587,10 +589,11 @@ void CHFA::weld_file_to_policy(CHFA &file_chfa, size_t &new_start,
|
||||
// to repeat
|
||||
assert(accept.size() == old_base_size);
|
||||
accept.resize(accept.size() + file_chfa.accept.size());
|
||||
size_t size = policy_perms.size();
|
||||
assert(policy_perms.size() < std::numeric_limits<ssize_t>::max());
|
||||
ssize_t size = (ssize_t) policy_perms.size();
|
||||
policy_perms.resize(size*2 + file_perms.size());
|
||||
// shift and double the policy perms
|
||||
for (size_t i = size - 1; size >= 0; i--) {
|
||||
for (ssize_t i = size - 1; i >= 0; i--) {
|
||||
policy_perms[i*2] = policy_perms[i];
|
||||
policy_perms[i*2 + 1] = policy_perms[i];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user