You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Lucas Galfaso (JIRA)" <ji...@apache.org> on 2012/05/11 23:13:50 UTC

[jira] [Created] (FELIX-3505) Bundle with a manifest of size 0 fails, but for the wrong reason

Lucas Galfaso created FELIX-3505:
------------------------------------

             Summary: Bundle with a manifest of size 0 fails, but for the wrong reason
                 Key: FELIX-3505
                 URL: https://issues.apache.org/jira/browse/FELIX-3505
             Project: Felix
          Issue Type: Bug
          Components: Framework
    Affects Versions: framework-4.0.2
         Environment: All
            Reporter: Lucas Galfaso
            Priority: Minor


If a bundle has a manifest of size 0, then Felix fails to install it but not because it detected that the manifest is invalid but because it tried to read passed the entry on the zip.

This can be tracked back to JarRevision::getMainAttributes that reads
// stuff

// Now read in the manifest in one go into the bytes array.
// The InputStream is already
// buffered and can handle up to 64K buffers in one go.
InputStream is = null;
try
{
  is = zipFile.getInputStream(entry);
  int i = is.read(bytes); // If size == 0, then i will be -1
  while (i < size) // This will be true
  {
    i += is.read(bytes, i, bytes.length - i); // This will throw java.lang.IndexOutOfBoundsException
  }
}
finally
{
  is.close();
}


One possible way to fix this would be to change
  int i = is.read(bytes);
  while (i < size)
  {
    i += is.read(bytes, i, bytes.length - i);
  }


to

for (int i = 0; i < size; i += is.read(bytes, i, bytes.length - i);



or just 

  int i = is.read(bytes);

to

  int i = 0;


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira