Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4354

NumberFormatException in COSParser

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.12
    • 2.0.13, 3.0.0 PDFBox
    • None
    • None

    Description

      Fuzzing PDF loading with JQF triggered two NumberFormatExceptions in different places.
      First exception:

      java.lang.NumberFormatException: For input string: "1f"
      	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      	at java.lang.Long.parseLong(Long.java:589)
      	at java.lang.Long.parseLong(Long.java:631)
      	at org.apache.pdfbox.pdfparser.COSParser.bfSearchForObjStreams(COSParser.java:2052)
      	at org.apache.pdfbox.pdfparser.COSParser.retrieveTrailer(COSParser.java:287)
      	at org.apache.pdfbox.pdfparser.PDFParser.initialParse(PDFParser.java:171)
      	at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:220)
      	at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1160)
      	at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1057)
          ...
      
      

      Second exception:

      java.lang.NumberFormatException: For input string: "am"
      	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      	at java.lang.Integer.parseInt(Integer.java:580)
      	at java.lang.Integer.parseInt(Integer.java:615)
      	at org.apache.pdfbox.pdfparser.COSParser.parseXrefTable(COSParser.java:2696)
      	at org.apache.pdfbox.pdfparser.COSParser.parseXref(COSParser.java:326)
      	at org.apache.pdfbox.pdfparser.COSParser.retrieveTrailer(COSParser.java:254)
      	at org.apache.pdfbox.pdfparser.PDFParser.initialParse(PDFParser.java:171)
      	at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:220)
      	at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1160)
      	at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1057)
          ...
      
      

      The Code used for fuzzing is

      PDDocument.load(inputStream)
      

      Attachments

        Activity

          People

            lehmi Andreas Lehmkühler
            rschimpf Robin Schimpf
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: