Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] File.toPath() usages may result in InvalidPathException

On 25.10.2017 00:10, Sohn, Matthias wrote:
On 24.10.17, 16:09, "jgit-dev-bounces@xxxxxxxxxxx on behalf of Marc Strapetz" <jgit-dev-bounces@xxxxxxxxxxx on behalf of marc.strapetz@xxxxxxxxxxx> wrote:

     I just wanted to point out that jgit has several unsafe usages of
     File.toPath() which may (and actually do) throw nasty
     InvalidPathExceptions. The vast majority of bug reports are caused by
     FileUtils.lastModified and are looking like:
java.nio.file.InvalidPathException
     	at sun.nio.fs.UnixPath.encode(UnixPath.java:147)
     	at sun.nio.fs.UnixPath.<init>(UnixPath.java:71)
     	at sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:281)
     	at java.io.File.toPath(File.java:2234)
     	at org.eclipse.jgit.util.FileUtils.lastModified(FileUtils.java:585)
     	at org.eclipse.jgit.util.FS.lastModified(FS.java:298)
     	at
     org.eclipse.jgit.internal.storage.file.FileSnapshot.save(FileSnapshot.java:109)
     	at
     org.eclipse.jgit.internal.storage.file.RefDirectory.scanRef(RefDirectory.java:953)
I think it would be reasonable to catch the InvalidPathException and
     convert into an IOException. I can provide a patch, if of interest.

+1, yes, please provide a patch

I've uploaded the patch at: https://git.eclipse.org/r/#/c/110593/

It's unclear to me when to stop propagating the IOExceptions. I've decided to do that early, in FS already, to keep the patch small.

-Marc


Back to the top