Limit the input size of pygments fuzzers (#10013)

This commit is contained in:
Julien Voisin 2023-04-11 18:25:09 +02:00 committed by GitHub
parent 00ac1ba576
commit 3264034794
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -22,6 +22,9 @@ import pygments.lexers
import pygments.util import pygments.util
def TestOneInput(data: bytes) -> int: def TestOneInput(data: bytes) -> int:
if len(data) > (2 << 18):
return
try: try:
lexer = pygments.lexers.guess_lexer(str(data)) lexer = pygments.lexers.guess_lexer(str(data))
except pygments.util.ClassNotFound: except pygments.util.ClassNotFound:

View File

@ -32,6 +32,8 @@ FORMATTERS = [BBCodeFormatter(), GroffFormatter(), HtmlFormatter(),
def TestOneInput(data: bytes) -> int: def TestOneInput(data: bytes) -> int:
if len(data) > (2 << 18):
return
fdp = atheris.FuzzedDataProvider(data) fdp = atheris.FuzzedDataProvider(data)
random_lexer = pygments.lexers.get_lexer_by_name(fdp.PickValueInList(LEXERS)) random_lexer = pygments.lexers.get_lexer_by_name(fdp.PickValueInList(LEXERS))
formatter = fdp.PickValueInList(FORMATTERS) formatter = fdp.PickValueInList(FORMATTERS)