Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-05-06 Thread Dan Xu
On 05/06/2013 06:59 AM, Florian Weimer wrote: On 05/03/2013 01:08 AM, Dan Xu wrote: Hi All, Thanks for all your comments. Based on the previous feedback, I have moved to the other approach, i.e., to fail file operations if the invalid NUL characher is found in a file path. As you know, due to

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-05-06 Thread Florian Weimer
On 05/03/2013 01:08 AM, Dan Xu wrote: Hi All, Thanks for all your comments. Based on the previous feedback, I have moved to the other approach, i.e., to fail file operations if the invalid NUL characher is found in a file path. As you know, due to the compatibility issue, we cannot throw an exce

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-05-03 Thread Xueming Shen
On 5/3/13 6:48 AM, Alan Bateman wrote: On 03/05/2013 00:08, Dan Xu wrote: Hi All, Thanks for all your comments. Based on the previous feedback, I have moved to the other approach, i.e., to fail file operations if the invalid NUL characher is found in a file path. As you know, due to the comp

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-05-03 Thread Alan Bateman
On 03/05/2013 00:08, Dan Xu wrote: Hi All, Thanks for all your comments. Based on the previous feedback, I have moved to the other approach, i.e., to fail file operations if the invalid NUL characher is found in a file path. As you know, due to the compatibility issue, we cannot throw an exce

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-05-02 Thread Dan Xu
Hi All, Thanks for all your comments. Based on the previous feedback, I have moved to the other approach, i.e., to fail file operations if the invalid NUL characher is found in a file path. As you know, due to the compatibility issue, we cannot throw an exception immediately in the File const

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-03-03 Thread Florian Weimer
On 03/03/2013 10:01 PM, Alan Bateman wrote: On 03/03/2013 20:00, Florian Weimer wrote: You check that the file ends with ".jpg", so it won't be interpreted by the web server, but the full extension is actually ".php\000.jpg", so you end up writing a ".php" file, which is. The application have

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-03-03 Thread Alan Bateman
On 03/03/2013 20:00, Florian Weimer wrote: You check that the file ends with ".jpg", so it won't be interpreted by the web server, but the full extension is actually ".php\000.jpg", so you end up writing a ".php" file, which is. The application have have the path String ".php\000.jpg" but when y

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-03-03 Thread Florian Weimer
On 02/27/2013 01:15 PM, Alan Bateman wrote: On 27/02/2013 12:07, Peter Levart wrote: What does a FileInputStream for example do when trying to open a File with embedded NUL chars on UNIX/Windows ? Does it try to open a "truncated" path? If so, then perhaps "normalize" could do that beforehand..

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-02-27 Thread Dan Xu
Because we cannot change the behaviour of File constructorsto error out the bad input immediately, the changes will be scattered all over many java io methods, especially methods in File.java, if we choose to reject bad inputs. And due to the delay of the rejection, it also brings a little head

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-02-27 Thread Mike Duigou
Ouch. That is unfortunate that File cannot reject bad input. Perhaps FileInputStream etc. should throw a specialized "Bad Filename" FnF for paths containing NUL if the underlying filesystem does not support NUL? Masking garbage input always really scares me. Mike On Feb 27 2013, at 02:40 , Ala

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-02-27 Thread Alan Bateman
On 27/02/2013 12:07, Peter Levart wrote: What does a FileInputStream for example do when trying to open a File with embedded NUL chars on UNIX/Windows ? Does it try to open a "truncated" path? If so, then perhaps "normalize" could do that beforehand... Yes, it's truncated. Dan's fix covers Fi

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-02-27 Thread Peter Levart
On 02/27/2013 03:52 AM, David Holmes wrote: On 27/02/2013 12:31 PM, Dan Xu wrote: Thank you, Mike. The reason not to throw out an exception is for the backward compatibility. Due to that, the constructorof File object with NUL willnever fail.While in NIO, it is defined in the spec to throw out

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-02-27 Thread Alan Bateman
On 27/02/2013 02:31, Dan Xu wrote: Thank you, Mike. The reason not to throw out an exception is for the backward compatibility. Due to that, the constructorof File object with NUL willnever fail.While in NIO, it is defined in the spec to throw out exceptions when invalid NUL character is foun

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-02-26 Thread David Holmes
On 27/02/2013 12:31 PM, Dan Xu wrote: Thank you, Mike. The reason not to throw out an exception is for the backward compatibility. Due to that, the constructorof File object with NUL willnever fail.While in NIO, it is defined in the spec to throw out exceptions when invalid NUL character is foun

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-02-26 Thread Dan Xu
Thank you, Mike. The reason not to throw out an exception is for the backward compatibility. Due to that, the constructorof File object with NUL willnever fail.While in NIO, it is defined in the spec to throw out exceptions when invalid NUL character is found. -Dan On 02/26/2013 04:33 PM,

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-02-26 Thread Martin Buchholz
Filenames are a lot like environment variables, and we already have code that rejects NUL chars in environment variable names: // Check that name is suitable for insertion into Environment map private static void validateVariable(String name) { if (name.indexOf('=') != -1 ||

Re: Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-02-26 Thread Mike Duigou
Hi Dan; External link to the bug (will hopefully work soon): http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8003992 I would like to better understand why silently removing the garbage null characters is the right answer here. If null is an invalid character for the underlying operating syst

Review Request for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly

2013-02-26 Thread Dan Xu
Hi All, Please help review the fix for JDK-8003992: File and other classes in java.io do not handle embedded nulls properly. Java IO, not like NIO, does not check NUL character in the given file path name, which brings confusion to Java users. This fix is going to address this issue by remov