DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42722>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42722

           Summary: Potential NullPointerException in
                    org.apache.catalina.servlets.CGIServlet
           Product: Tomcat 6
           Version: 6.0.11
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


There is a potential NPE in CGIServlet, even if it's unlikely it may happen.

The following patch resolves this problem:

Index:
F:/Workspace/Apache2/tomcat6/java/org/apache/catalina/servlets/CGIServlet.java
===================================================================
---
F:/Workspace/Apache2/tomcat6/java/org/apache/catalina/servlets/CGIServlet.java
(revision 548385)
+++
F:/Workspace/Apache2/tomcat6/java/org/apache/catalina/servlets/CGIServlet.java
(working copy)
@@ -1631,7 +1631,6 @@
              * with major modifications by Martin Dengler
              */
             Runtime rt = null;
-            InputStream cgiOutput = null;
             BufferedReader commandsStdErr = null;
             BufferedOutputStream commandsStdIn = null;
             Process proc = null;
@@ -1700,7 +1699,9 @@
                     new HTTPHeaderInputStream(proc.getInputStream());
                 BufferedReader cgiHeaderReader =
                     new BufferedReader(new InputStreamReader(cgiHeaderStream));
-            
+
+                InputStream cgiOutput = null;
+
                 while (isRunning) {
                     try {
                         //set headers
@@ -1763,7 +1764,10 @@
                 } //replacement for Process.waitFor()
     
                 // Close the output stream used
-                cgiOutput.close();
+                if (cgiOutput != null)
+                {
+                    cgiOutput.close();
+                }
             }
             catch (IOException e){
                 log ("Caught exception " + e);

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to