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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20210627182305.4721-1-dwaipayanray1@gmail.com>
Date:   Sun, 27 Jun 2021 23:53:05 +0530
From:   Dwaipayan Ray <dwaipayanray1@...il.com>
To:     joe@...ches.com, apw@...onical.com
Cc:     lukas.bulwahn@...il.com, linux-kernel@...r.kernel.org,
        Dwaipayan Ray <dwaipayanray1@...il.com>,
        Alejandro Colomar <alx.manpages@...il.com>
Subject: [PATCH] checkpatch: Fix regex for do without braces

The regular expression for detecting do without braces
also passes when checkpatch encounters the "double"
keyword. This causes wrong recalculation of $stat in
checkpatch which can cause false positives.

Fix the regex to avoid the above. Also update the comments
for the check.

Reported-by: Alejandro Colomar <alx.manpages@...il.com>
Signed-off-by: Dwaipayan Ray <dwaipayanray1@...il.com>
---
 scripts/checkpatch.pl | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8d19beca3538..cba68420fd55 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5488,9 +5488,8 @@ sub process {
 			}
 		}
 
-# Check for illegal assignment in if conditional -- and check for trailing
-# statements after the conditional.
-		if ($line =~ /do\s*(?!{)/) {
+# If we have sufficient context detect and handle do without braces ({).
+		if ($line =~ /do\b\s*(?!{)/) {
 			($stat, $cond, $line_nr_next, $remain_next, $off_next) =
 				ctx_statement_block($linenr, $realcnt, 0)
 					if (!defined $stat);
@@ -5511,6 +5510,9 @@ sub process {
 								$offset} = 1;
 			}
 		}
+
+# Check for illegal assignment in if conditional -- and check for trailing
+# statements after the conditional.
 		if (!defined $suppress_whiletrailers{$linenr} &&
 		    defined($stat) && defined($cond) &&
 		    $line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) {
-- 
2.28.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ