forked from luck/tmp_suning_uos_patched
checkpatch: improve octal permissions tests
Add world writable permissions tests for the various functions like debugfs etc... Add $String type for $FuncArg so that string constants are matched. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
62ec818f55
commit
c0a5c89858
|
@ -298,6 +298,7 @@ our $Binary = qr{(?i)0b[01]+$Int_type?};
|
|||
our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?};
|
||||
our $Int = qr{[0-9]+$Int_type?};
|
||||
our $Octal = qr{0[0-7]+$Int_type?};
|
||||
our $String = qr{"[X\t]*"};
|
||||
our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
|
||||
our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
|
||||
our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
|
||||
|
@ -517,7 +518,7 @@ our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*};
|
|||
|
||||
our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
|
||||
our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*};
|
||||
our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)};
|
||||
our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant|$String)};
|
||||
|
||||
our $declaration_macros = qr{(?x:
|
||||
(?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,2}\s*\(|
|
||||
|
@ -5261,6 +5262,9 @@ sub process {
|
|||
length($val) ne 4)) {
|
||||
ERROR("NON_OCTAL_PERMISSIONS",
|
||||
"Use 4 digit octal (0777) not decimal permissions\n" . $herecurr);
|
||||
} elsif ($val =~ /^$Octal$/ && (oct($val) & 02)) {
|
||||
ERROR("EXPORTED_WORLD_WRITABLE",
|
||||
"Exporting writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user