]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checksrc: fix possible endless loop when detecting `BANNEDFUNC`
authorViktor Szakats <commit@vsz.me>
Mon, 29 Sep 2025 23:46:33 +0000 (01:46 +0200)
committerViktor Szakats <commit@vsz.me>
Tue, 30 Sep 2025 09:32:12 +0000 (11:32 +0200)
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

index b737961899f15e0e99b2aa787a3a3f6aeb49133a..23c9ef530107ee70224352f372747e632368efbd 100755 (executable)
@@ -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;