lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 11 Apr 2007 00:37:44 +0400
From:	Alexey Dobriyan <adobriyan@...il.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	"Robert P. J. Day" <rpjday@...dspring.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] Add spaces on either side of case "..." operator.

On Tue, Apr 10, 2007 at 09:05:55AM -0700, Andrew Morton wrote:
> On Tue, 10 Apr 2007 07:23:35 -0400 (EDT) "Robert P. J. Day" <rpjday@...dspring.com> wrote:
> > Following the programming advice laid down in the gcc manual, make
> > sure the case "..." operator has spaces on either side.

> > http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Case-Ranges.html#Case-Ranges:
> >
> >   "Be careful: Write spaces around the ..., for otherwise it may be
> > parsed wrong when you use it with integer values."

> > --- a/kernel/audit.c
> > +++ b/kernel/audit.c
> > @@ -515,8 +515,8 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type)
> >  			err = -EPERM;
> >  		break;
> >  	case AUDIT_USER:
> > -	case AUDIT_FIRST_USER_MSG...AUDIT_LAST_USER_MSG:
> > -	case AUDIT_FIRST_USER_MSG2...AUDIT_LAST_USER_MSG2:
> > +	case AUDIT_FIRST_USER_MSG ... AUDIT_LAST_USER_MSG:
> > +	case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2:
>
> hm... We have:
>
> #define AUDIT_FIRST_USER_MSG    1100    /* Userspace messages mostly uninteresting to kernel */
> #define AUDIT_USER_AVC          1107    /* We filter this differently */
> #define AUDIT_LAST_USER_MSG     1199
>
> and CPP turns that into
>
>  case 1100 ...1199:
>  case 2100 ...2999:
>
> and it does the same when the comments are stripped from the #defines.
>
> So we were saved by the trailing space which cpp added to the expanded
> macro.  I wonder why cpp did that, and to what extent one can rely cpp
> doing that.

The only reason I can come up with is temporary files with preprocessing
output. Imagine the code:

	#define FOO 1
	FOO.

Here we have
a) replacement list of token FOO consists of one token -- 1,
b) pp-token list after preprocessing consists of 4 pp-tokens: newline, 1, .,
   newline

BUT, write it to temporary file:

	
	1.

Whoops, there are 3 or 4 pp-tokens? If you don't know history, there are
3, if you do, there are 4.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ