[apparmor] [patch] Let the parser reject ambiguous unit 'm' for rlimit rttime
Seth Arnold
seth.arnold at canonical.com
Fri May 22 18:37:59 UTC 2015
On Fri, May 22, 2015 at 01:39:40PM +0200, Christian Boltz wrote:
> === modified file 'parser/parser_yacc.y'
> --- parser/parser_yacc.y 2015-03-25 22:09:26 +0000
> +++ parser/parser_yacc.y 2015-05-22 00:07:48 +0000
> @@ -885,6 +885,8 @@
> yyerror("RLIMIT '%s' invalid value %s\n", $4, $6);
> if (*end == '\0') {
> value = tmp;
> + } else if (*end == 'm\0') {
NAK, 'm\0' does not do what you want it to do. :)
'' delimits chars, and in a hilarious piece of history, enclosing
multiple chars in '' is perfectly legal in C, but -- and this is where it
gets extremely funny -- the result is implementation defined. GCC chooses
to let you build large numbers this way:
https://gcc.gnu.org/onlinedocs/cpp/Implementation-defined-behavior.html
In the end you're comparing a single character against the value 27904.
Probably strcmp("m",...) == 0 is the best approach here. There might be
something more clever.
> + yyerror("RLIMIT '%s' ambiguous value %s - use either 'ms' or 'minutes'\n", $4, $6);
Minor point here, it'd be best to use "ambiguous unit" in this case.
Thanks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150522/13a200db/attachment.pgp>
More information about the AppArmor
mailing list