From dd37d6970cfd8b4cf47ebd469f03772813b92c23 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 30 Sep 2025 01:46:33 +0200 Subject: [PATCH] checksrc: fix possible endless loop when detecting `BANNEDFUNC` If the source line had square brackets before the match, the stripping of the banned function left the original line intact, and repeated the check on it forever. E.g. with banned function `open` in `lib518.c`: ```c t518_testfd[0] = open(DEV_NULL, O_RDONLY); ``` Closes #18775 --- scripts/checksrc.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl index b737961899..23c9ef5301 100755 --- a/scripts/checksrc.pl +++ b/scripts/checksrc.pl @@ -902,6 +902,8 @@ sub scanfile { "use of $bad is banned"); my $replace = 'x' x (length($bad) + 1); $prefix =~ s/\*/\\*/; + $prefix =~ s/\[/\\[/; + $prefix =~ s/\]/\\]/; $suff =~ s/\(/\\(/; $l =~ s/$prefix$bad$suff/$prefix$replace/; goto again; -- 2.47.3