]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
docs: kdoc_re: don't go past the end of a line
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 2 Mar 2026 16:40:45 +0000 (17:40 +0100)
committerJonathan Corbet <corbet@lwn.net>
Tue, 3 Mar 2026 17:47:24 +0000 (10:47 -0700)
The logic which checks if the line ends with ";" is currently
broken: it may try to read past the buffer.

Fix it by checking before trying to access line[pos].

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <bce51ba0260a053a0ec55a7375d6ed7a7c08026c.1772469446.git.mchehab+huawei@kernel.org>

tools/lib/python/kdoc/kdoc_re.py

index 774dd747ecb0200bfa9142583bb863d94cfc4e00..6c44fcce041564acbf7a00aa69767fcf3df64661 100644 (file)
@@ -269,7 +269,7 @@ class NestedMatch:
             out += new_sub
 
             # Drop end ';' if any
-            if line[pos] == ';':
+            if pos < len(line) and line[pos] == ';':
                 pos += 1
 
             cur_pos = pos