You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Petr Jiricka <pe...@netbeans.com> on 2000/05/09 14:42:20 UTC

[PATCH] NPE in include directive

Hello,

I haven't tried to reproduce this bug lately, but some time ago I noticed
that when a page included by include directive is not found, a null value is
passed to FileInputStream, which causes NullPointerException to be thrown
(at least on Windows). I think ParseException should be thrown instead. The
following patch thus just checks whether the file returned by getRealPath()
is null.

Cheers
Petr


Index: JspReader.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReade
r.java,v
retrieving revision 1.15
diff -u -r1.15 JspReader.java
--- JspReader.java      2000/05/04 21:37:21     1.15
+++ JspReader.java      2000/05/09 12:28:26
@@ -167,7 +167,12 @@
        String longName = (context == null)
            ? file.getAbsolutePath()
            : context.getRealPath(file.toString());
-
+
+       if (longName == null)
+            throw new
ParseException(Constants.getString("jsp.error.file.not.found",
+                                                         new Object[] {
+                                                             file
+                                                         }));
        int fileid = registerSourceFile(longName);

         if (fileid == -1)

Re: [PATCH] NPE in include directive

Posted by MANDAR RAJE <ma...@pathfinder.eng.sun.com>.
Hi Petr,

 Thanks for the patch. I will make the necessary changes
to the source.

Mandar.

Petr Jiricka wrote:
> 
> Hello,
> 
> I haven't tried to reproduce this bug lately, but some time ago I noticed
> that when a page included by include directive is not found, a null value is
> passed to FileInputStream, which causes NullPointerException to be thrown
> (at least on Windows). I think ParseException should be thrown instead. The
> following patch thus just checks whether the file returned by getRealPath()
> is null.
> 
> Cheers
> Petr
> 
> Index: JspReader.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReade
> r.java,v
> retrieving revision 1.15
> diff -u -r1.15 JspReader.java
> --- JspReader.java      2000/05/04 21:37:21     1.15
> +++ JspReader.java      2000/05/09 12:28:26
> @@ -167,7 +167,12 @@
>         String longName = (context == null)
>             ? file.getAbsolutePath()
>             : context.getRealPath(file.toString());
> -
> +
> +       if (longName == null)
> +            throw new
> ParseException(Constants.getString("jsp.error.file.not.found",
> +                                                         new Object[] {
> +                                                             file
> +                                                         }));
>         int fileid = registerSourceFile(longName);
> 
>          if (fileid == -1)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org

Re: [PATCH] NPE in include directive

Posted by MANDAR RAJE <ma...@pathfinder.eng.sun.com>.
Hi Petr,

 I tried it and think it is fixed already.

Thanks,
Mandar.

Petr Jiricka wrote:
> 
> Hello,
> 
> I haven't tried to reproduce this bug lately, but some time ago I noticed
> that when a page included by include directive is not found, a null value is
> passed to FileInputStream, which causes NullPointerException to be thrown
> (at least on Windows). I think ParseException should be thrown instead. The
> following patch thus just checks whether the file returned by getRealPath()
> is null.
> 
> Cheers
> Petr
> 
> Index: JspReader.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReade
> r.java,v
> retrieving revision 1.15
> diff -u -r1.15 JspReader.java
> --- JspReader.java      2000/05/04 21:37:21     1.15
> +++ JspReader.java      2000/05/09 12:28:26
> @@ -167,7 +167,12 @@
>         String longName = (context == null)
>             ? file.getAbsolutePath()
>             : context.getRealPath(file.toString());
> -
> +
> +       if (longName == null)
> +            throw new
> ParseException(Constants.getString("jsp.error.file.not.found",
> +                                                         new Object[] {
> +                                                             file
> +                                                         }));
>         int fileid = registerSourceFile(longName);
> 
>          if (fileid == -1)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org