mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
parser: send key as integer on the dfa of sysv mqueue
The key of SYSV message queues is an integer and the kernel uses an integer to store the key. In order to improve performance when travelling the DFA in the kernel, we should use an integer instead of the string. Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
This commit is contained in:
parent
223036d952
commit
106b3d16da
1 changed files with 10 additions and 4 deletions
|
@ -244,13 +244,19 @@ int mqueue_rule::gen_policy_re(Profile &prof)
|
|||
if (qtype != mqueue_posix) {
|
||||
std::ostringstream buffer;
|
||||
buffer << "\\x" << std::setfill('0') << std::setw(2) << std::hex << AA_CLASS_SYSV_MQUEUE;
|
||||
buf.assign(buffer.str());
|
||||
|
||||
if (qname) {
|
||||
if (!convert_entry(buf, qname))
|
||||
goto fail;
|
||||
int key;
|
||||
sscanf(qname, "%d", &key);
|
||||
u32 tmp = htobe32((u32) key);
|
||||
u8 *byte = (u8 *) &tmp;
|
||||
for (int i = 0; i < 4; i++){
|
||||
buffer << "\\x" << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned int>(byte[i]);
|
||||
}
|
||||
} else {
|
||||
buf += default_match_pattern;
|
||||
buffer << "....";
|
||||
}
|
||||
buf.assign(buffer.str());
|
||||
vec[0] = buf.c_str();
|
||||
|
||||
if (label) {
|
||||
|
|
Loading…
Add table
Reference in a new issue