[apparmor] [PATCH 1/5] Add basic string matching to the hfa
John Johansen
john.johansen at canonical.com
Wed Dec 28 05:30:38 UTC 2011
On 12/27/2011 08:13 PM, Seth Arnold wrote:
> Yay! I love patches. :)
>
>
> On Tue, Dec 27, 2011 at 6:49 PM, John Johansen
> <john.johansen at canonical.com> wrote:
>> Add the ability to match strings directly from the hfa instead of needing
>> to build a cfha.
>>
>> Signed-off-by: John Johansen<john.johansen at canonical.com>
>
>
>> --- a/parser/libapparmor_re/hfa.cc
>> +++ b/parser/libapparmor_re/hfa.cc
>> @@ -30,6 +30,7 @@
>> #include<ostream>
>> #include<iostream>
>> #include<fstream>
>> +#include<string.h>
>
> Should this be<cstring> or<string>? I never figured out the C++ rules.
>
>> #include "expr-tree.h"
>> #include "hfa.h"
>> @@ -267,6 +268,19 @@ DFA::~DFA()
>> delete *i;
>> }
>>
>> +State *DFA::match_len(State *state, const char *str, size_t len)
>> +{
>> + for (; len> 0; ++str, --len)
>> + state = state->next(*str);
>> +
>> + return state;
>> +}
>> +
>> +State *DFA::match(const char *str)
>> +{
>> + return match_len(start, str, strlen(str));
>> +}
>
> It seems unfortunate to me that this walks the string _twice_ -- once for
> strlen, once for the match_len call. Is this me prematurely optimizing? Or
> is this a potential performance problem?
>
Yeah basically I just haven't gotten to it yet. I needed the base patch for
other things. Not that it will take more than a couple minutes to optimize
this
More information about the AppArmor
mailing list