[apparmor] [patch] Fix dfa minimization

Steve Beattie steve at nxnw.org
Fri Jan 10 00:29:45 UTC 2014


On Thu, Jan 09, 2014 at 03:08:10PM -0800, John Johansen wrote:
> On 01/08/2014 09:06 PM, John Johansen wrote:
> > On 01/08/2014 02:50 PM, Steve Beattie wrote:
> >> On Sat, Jan 04, 2014 at 03:09:43AM -0800, John Johansen wrote:
> >>> And the patch (yes I died a little with this one, guess what code is now on
> >>> my hit list). And yes it is just removing casting from the one line and
> >>> changing it in the macro
> >>>
> >>> Signed-off-by: John Johansen <john.johansen at canonical.com>
> >>>
> >>> oh and nominated for the 2.8 series as well
> >>
> 
> And a slight revision to the previous patch. The free entry list tracking
> wasn't being correctly resized to be the same as the next/check table
> which lead to some problems if the optimal value was < 256

Yeah, not resizing the free list to match was causing the parser to
segfault in a few of the language test cases.

> === modified file 'parser/libapparmor_re/chfa.cc'
> --- parser/libapparmor_re/chfa.cc	2013-12-28 11:37:22 +0000
> +++ parser/libapparmor_re/chfa.cc	2014-01-09 11:07:45 +0000
> @@ -98,10 +98,10 @@
>  	default_base.push_back(make_pair(dfa.nonmatching, 0));
>  	num.insert(make_pair(dfa.nonmatching, num.size()));
>  
> -	accept.resize(dfa.states.size());
> -	accept2.resize(dfa.states.size());
> -	next_check.resize(optimal);
> -	free_list.resize(optimal);
> +	accept.resize(max(dfa.states.size(),2ul));
> +	accept2.resize(max(dfa.states.size(),2ul));
> +	next_check.resize(max(optimal,256ul));
> +	free_list.resize(next_check.size());

My only very, very minor nit would be to add a space after the comma in
between the arguments, to help my mental lexer. Otherwise,
Acked-by: Steve Beattie <steve at nxnw.org>


-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140109/0a6bc4cc/attachment-0001.pgp>


More information about the AppArmor mailing list