Skip to content

parsing error on '0u'  #587

@whyprogrammer

Description

@whyprogrammer

I find a crash in the newest version by libfuzzer.

ValueError: invalid literal for int() with base 10: '0u'
Traceback (most recent call last):
  File "/data/wanghy/code/LLM_DIRECTED_INPUT/py_llm_test/repos/pycparser/fuzz_c_parser.py", line 35, in TestOneInput
    _c_parser.parse(
    ~~~~~~~~~~~~~~~^
        c_source,
        ^^^^^^^^^
        ''
        ^^
    )
    ^
  File "/data/wanghy/conda_env/envs/python_DIG/lib/python3.13/site-packages/pycparser/c_parser.py", line 147, in parse
    return self.cparser.parse(
           ~~~~~~~~~~~~~~~~~~^
            input=text,
            ^^^^^^^^^^^
            lexer=self.clex,
            ^^^^^^^^^^^^^^^^
            debug=debug)
            ^^^^^^^^^^^^
  File "/data/wanghy/conda_env/envs/python_DIG/lib/python3.13/site-packages/pycparser/ply/yacc.py", line 331, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/wanghy/conda_env/envs/python_DIG/lib/python3.13/site-packages/pycparser/ply/yacc.py", line 1061, in parseopt_notrack
    lookahead = get_token()     # Get the next token
  File "/data/wanghy/conda_env/envs/python_DIG/lib/python3.13/site-packages/pycparser/c_lexer.py", line 76, in token
    self.last_token = self.lexer.token()
                      ~~~~~~~~~~~~~~~~^^
  File "/data/wanghy/conda_env/envs/python_DIG/lib/python3.13/site-packages/pycparser/ply/lex.py", line 350, in token
    newtok = func(tok)
  File "/data/wanghy/conda_env/envs/python_DIG/lib/python3.13/site-packages/pycparser/c_lexer.py", line 329, in t_ppline_NEWLINE
    self.lexer.lineno = int(self.pp_line)
                        ~~~^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '0u'

pycparser_crash.zip

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions