Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • asm asm
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 6
    • Issues 6
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • asmasm
  • asmasm
  • Issues
  • #317816
Closed
Open
Issue created Mar 13, 2018 by Jussi Judin@barro

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
Time tracking