You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2012/02/14 11:18:23 UTC

DO NOT REPLY [Bug 52665] New: An incomplete fix for the NPE bug in ZipFileZipEntrySource.java

https://issues.apache.org/bugzilla/show_bug.cgi?id=52665

             Bug #: 52665
           Summary: An incomplete fix for the NPE bug in
                    ZipFileZipEntrySource.java
           Product: POI
           Version: unspecified
          Platform: PC
            Status: NEW
          Severity: critical
          Priority: P2
         Component: POI Overall
        AssignedTo: dev@poi.apache.org
        ReportedBy: lianggt08@sei.pku.edu.cn
    Classification: Unclassified


The fix revision 1179452 was aimed to remove an NPE bug on the  "zipArchive" in
the method "close" of the file
"/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java"
, but it is incomplete. 
Since the "zipArchive" could be null during the run-time execution, its value
should also be null-checked before being dereferenced in other methods. 

The buggy code locations the same fix needs to be applied at are as bellows: 

Line 44 of the method "getEntries()" : 
    public Enumeration<? extends ZipEntry> getEntries() {
[Line 44]      return zipArchive.entries();
   }

Line  48 of the method "getInputStream()" :
  public InputStream getInputStream(ZipEntry entry) throws IOException {
[Line 48]      return zipArchive.getInputStream(entry);
   }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 52665] An incomplete fix for the NPE bug in ZipFileZipEntrySource.java

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52665

lianggt08@sei.pku.edu.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #2 from lianggt08@sei.pku.edu.cn 2012-02-15 06:03:36 UTC ---
If the method "close" is called, zipArchive will be null. After that, if the
methods "getEntries()" and "getInputStream()" are called, NPE will happen at
the code line 44 and 48.  

Please check the bug issue 51949 at
https://issues.apache.org/bugzilla/show_bug.cgi?id=51949  for the method
"close": 


    public void close() throws IOException {
        zipArchive.close();
        zipArchive = null;
    }



Thanks.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 52665] An incomplete fix for the NPE bug in ZipFileZipEntrySource.java

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52665

--- Comment #4 from lianggt08@sei.pku.edu.cn 2012-02-15 11:41:37 UTC ---
OK.
Throwing an IllegalStateException("zip file closed") will be much better. 
Thanks.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 52665] An incomplete fix for the NPE bug in ZipFileZipEntrySource.java

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52665

Nick Burch <ni...@alfresco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #5 from Nick Burch <ni...@alfresco.com> 2012-02-15 11:51:25 UTC ---
As of r1244450, we now through an IllegalArgumentException for this case

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 52665] An incomplete fix for the NPE bug in ZipFileZipEntrySource.java

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52665

--- Comment #3 from Yegor Kozlov <ye...@dinom.ru> 2012-02-15 08:16:08 UTC ---
What do you expect from  "getEntries()" and "getInputStream()": return null or
throw a more sensible exception? 

I would say that instead of the NPE they should throw
IllegalStateException("zip file closed"), the way java.util.ZipFile does. Does
it seem the right fix for you? 

Yegor

(In reply to comment #2)
> If the method "close" is called, zipArchive will be null. After that, if the
> methods "getEntries()" and "getInputStream()" are called, NPE will happen at
> the code line 44 and 48.  
> 
> Please check the bug issue 51949 at
> https://issues.apache.org/bugzilla/show_bug.cgi?id=51949  for the method
> "close": 
> 
> 
>     public void close() throws IOException {
>         zipArchive.close();
>         zipArchive = null;
>     }
> 
> 
> 
> Thanks.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 52665] An incomplete fix for the NPE bug in ZipFileZipEntrySource.java

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52665

lianggt08@sei.pku.edu.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lianggt08@sei.pku.edu.cn
         OS/Version|                            |All

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 52665] An incomplete fix for the NPE bug in ZipFileZipEntrySource.java

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52665

Nick Burch <ni...@alfresco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Nick Burch <ni...@alfresco.com> 2012-02-14 12:59:12 UTC ---
I'm not sure that zipArchive should ever be null - how are you triggering this?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org