lkml.org 
[lkml]   [2000]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Modprobe local root exploit
Date
On Tue, 14 Nov 2000, David Relson wrote:
> At 06:29 AM 11/14/00, Daniel Phillips wrote:
>
> >Heading in the right direction, but this is equivalent to:
> >
> > if (isalnum(*p) && *p != '-' && *p != '_') return -EINVAL;
> >
> >which is faster, smaller and easier to read.
>
> Almost right, but you forgot to negate isalnum(). Should be:
>
> if (!isalnum(*p) && *p != '-' && *p != '_') return -EINVAL;
>
> or
> if (! (isalnum(*p) || *p == '-' || *p == '_')) return -EINVAL;
>
> I think I prefer the older version with "continue" as I don't have to think
> about all the negatives ("!"), i.e.
>
> for ( ... )
> {
> if ( isalnum(*p) || *p == '-' || *p == '_' )
> continue;
> return -EINVAL;
> }
>

I reserve the right to make coding errors, thanks for not letting it get
written into history :-)

How about:

for ( ... ) if (!isalnum(*p) && !strchr("-_", *p)) return -EINVAL;
--
Daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:45    [from the cache]
©2003-2011 Jasper Spaans. Advertise on this site