This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 28755 - Buffer overflow in NbInstaller
Summary: Buffer overflow in NbInstaller
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Module System (show other bugs)
Version: 3.x
Hardware: PC Other
: P2 blocker (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on:
Blocks: 26786
  Show dependency tree
 
Reported: 2002-11-14 16:35 UTC by _ ttran
Modified: 2008-12-23 08:36 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ ttran 2002-11-14 16:35:16 UTC
>    private void readUpTillNullByte(InputStream
is) throws IOException {
>         if (tmpbuf == null) {
>             tmpbuf = new byte[4096];
>         }

Jesse, you're hoping that MANIFEST is always
smaller than 4K.  Not right.  If the jar is signed
then its MANIFEST is easily much bigger.  Cf
{s1s}/modules/autoload/activation.jar
Comment 1 Jesse Glick 2002-11-14 17:35:04 UTC
Strange... the code was originally (1.47) supposed to be written to
support any size manifest, of course, but there was a logic bug which
was found quickly by someone with a bigger manifest (activation.jar as
I recall) and then corrected (1.48).

On what platform do you get this? How was it observed?
Comment 2 Jesse Glick 2002-11-14 20:20:42 UTC
Writing a unit test...
Comment 3 Jesse Glick 2002-11-14 20:58:47 UTC
Works for me with the original code (before your buffer size
increase), using

1. a small manifest

2. a bigger one (> 4k)

3. an even bigger one (about 10k)

So the unit test (which I will commit soon) says. If you have any more
info on how to reproduce, I will add it to the test of course.
Comment 4 Jesse Glick 2002-11-15 15:11:10 UTC
Trung I will roll back your "hot patch" in the absence of any
information on why you thought it was needed. 4k was chosen as a
buffer size large enough to capture most manifests in their entirety
without allocating too large a buffer. If a manifest exceeds that
limit the buffer is expanded until it will fit.
Comment 5 _ ttran 2002-11-15 15:35:33 UTC
wait, it happens in Dublin build when NbInstaller loads manifest cache
entry for activation.jar.  If you want I can investigate it further
Comment 6 Jesse Glick 2002-11-24 18:57:55 UTC
Well, I personally saw an EOFException on Trung's machine, but I
cannot reproduce on my own:

1. Made a full EE English build.

2. Ran it with a fresh user dir. JDK 1.4.1, Linux kernel 2.4.18,
userdir filesystem = RAM disk.

3. Shut down, restarted.

4. No exception or obvious problem.

5. all-manifests.dat definitely contains entry for activation.jar, as
well as for the much longer mail.jar.

I will try to rewrite the code to make it simpler anyway. However I
will not be able to confirm that the rewrite fixes anything, since I
cannot reproduce the original problem.
Comment 7 Jesse Glick 2002-11-28 13:55:52 UTC
I rewrote the code to use an in-memory byte array, which is probably
about the same speed, definitely simpler to read, hopefully more
robust. The same unit test passes. Tried with S1S EE, seemed OK.
Comment 8 Jesse Glick 2002-11-28 19:10:28 UTC
committed   * Up-To-Date  1.59       
core/src/org/netbeans/core/modules/NbInstaller.java
added       * Up-To-Date  1.1        
core/test/unit/src/org/netbeans/core/modules/NbInstallerTest9.java
committed   * Up-To-Date  1.16       
core/test/unit/src/org/netbeans/core/modules/build.xml
added       * Up-To-Date  1.1        
core/test/unit/src/org/netbeans/core/modules/jars/big-manifest.mf
added       * Up-To-Date  1.1        
core/test/unit/src/org/netbeans/core/modules/jars/little-manifest.mf
added       * Up-To-Date  1.1        
core/test/unit/src/org/netbeans/core/modules/jars/medium-manifest.mf
Comment 9 Marian Mirilovic 2004-03-15 15:19:43 UTC
verified