untrusted string optimization
David Woodhouse
dwmw2 at infradead.org
Wed May 18 09:49:04 UTC 2005
On Mon, 2005-05-16 at 16:36 -0400, Steve Grubb wrote:
> I was looking at some ascii charts trying to interpret an untrusted string and
> realized something. We have this test in audit_log_untrustedstring() in
> audit.c:
>
> if (*p == '"' || *p == ' ' || *p < 0x20 || *p > 0x7f) {
>
> It turns out that space is hex 20. So we could have:
>
> if (*p == '"' || *p < 0x21 || *p > 0x7f) {
>
> and have one less compare in that loop.
Look at the assembly code. If that change actually does give us one
fewer compare, then file a GCC bug.
Given that it's already upstream, we might as well leave it the way it
is. As it is, it clearly documents the fact that a space is going to
cause the string to be quoted.
--
dwmw2
More information about the Linux-audit
mailing list