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
This commit is contained in:
Viktor Szakats 2025-09-30 01:46:33 +02:00
parent 20142f5d06
commit dd37d6970c
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201

View file

@ -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;