Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
    • Contribute to GitLab
  • Sign in
asm
asm
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Packages
    • Packages
    • Container Registry
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • asm
  • asmasm
  • Issues
  • #317816

Closed
Open
Opened Mar 13, 2018 by Jussi Judin@barro
  • Report abuse
  • New issue
Report abuse New issue

ClassReader constructor goes into infinite loop on zero length input streams

Following code leads into an infinite loop with ClassReader constructor when args[0] is an empty file:

public class Asm61InfiniteLoop
{
    public static void main(String[] args) throws java.io.IOException
    {
        java.io.FileInputStream input = new java.io.FileInputStream(args[0]);
        new org.objectweb.asm.ClassReader(input);
    }
}

It looks like the following snippet in the constructor is the culprit where data leads into a zero length array with zero length files and the bytes read from the actual stream never get to -1:

      byte[] data = new byte[inputStream.available()];
      int bytesRead;
      while ((bytesRead = inputStream.read(data, 0, data.length)) != -1) {
        outputStream.write(data, 0, bytesRead);
      }

I would expect this to throw an exception about invalid class data or similar. Other constructors relying on byte[] data being at least 6 elements long lead into out of bounds exception. That is a little bit better, but still weird from user's perspective.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
2
Labels
#bug core
Assign labels
  • View project labels
Reference: asm/asm#317816