[jira] [Commented] (VFS-437) [FTP] Program crashes when StackOverFlow Exception happens from pulling a softlinked directory that link to the directory that has the same name one level above

2012-10-05 Thread Dennis Zhu (JIRA)

[ 
https://issues.apache.org/jira/browse/VFS-437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13470857#comment-13470857
 ] 

Dennis Zhu commented on VFS-437:


I just tested again with my setup with your patch applied and the code seems to 
work: if the link is circular, then we return it as imaginary and does not 
allow the user to access it. Furthermore, I tested it on the case of Vol1 - 
... - /Vol1 and ultimately VFS will evaluate through all the links and arrive 
at the same /Vol1 and catch the imaginary file and refuse to access the link. 
My setup was such that Vol1 will link to vol1, vol1 then links to vol3, then 
vol3 ultimately links back to /Vol1, so Vol1 - vol1 - vol3 - /Vol1.

Now, I am able to see a problem if I have this setup:

Vol1 - Vol3
Vol3 - Vol1

That WILL cause a StackOverFlowError. However, even though the user is allowed 
to setup that link, the Linux file system itself refuses to evaluate those 
links with the error -bash: cd: Vol1: Too many levels of symbolic links.

As far as checking for circular links in doGetChildren(), I don't think there 
is a need because before we ever hit the doGetChildren code, we'll always hit 
the doGetType code first. Having a circular link check inside doGetChildren 
would be redundant. 

 [FTP] Program crashes when StackOverFlow Exception happens from pulling a 
 softlinked directory that link to the directory that has the same name one 
 level above 
 -

 Key: VFS-437
 URL: https://issues.apache.org/jira/browse/VFS-437
 Project: Commons VFS
  Issue Type: Bug
Affects Versions: 2.0
 Environment: java version 1.7.0_02
 Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
 Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
 Linux version 2.6.18-238.el5 (mockbu...@builder10.centos.org) (gcc version 
 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Jan 13 15:51:15 EST 2011
Reporter: Jason
Priority: Blocker
 Fix For: 2.1

 Attachments: VFS-437.diff, vfs-437-v2-gg.diff


 With the setting below, StackOverFlow exceptions occur and server crashes
 set the builder.setUserDirlsRoot (opt, true)
 Attept to pull with:
 ftp://root:password@ip:/Vol1
 Vol directory has the following info
 lrwxrwxrwx  1 root root5 Oct  5  2007 Vol1 - /Vol1
 When it tries to look for the parent of the Vol1, it goes back to the same 
 Vol1, which causes a infinite loop that eventually creates stackoverflow 
 exception.
 The problem is inside the doGetType() method in FtpFileObject
 @Override
 protected FileType doGetType()
 throws Exception
 {
 // VFS-210
 synchronized (getFileSystem())
 {
 if (this.fileInfo == null)
 {
 getInfo(false);
 }
 if (this.fileInfo == UNKNOWN)
 {
 return FileType.IMAGINARY;
 }
 else if (this.fileInfo.isDirectory())
 {
 return FileType.FOLDER;
 }
 else if (this.fileInfo.isFile())
 {
 return FileType.FILE;
 }
 else if (this.fileInfo.isSymbolicLink())
 {
 return getLinkDestination().getType();
 }
 }
 throw new FileSystemException(vfs.provider.ftp/get-type.error, 
 getName());
 }
 It will keep hitting the else if (this.fileinfo.isSymbolicLink()) condition 
 and the fileinfo displayed is always the Vol1 under root directory.
 Exception is shown below
 java.lang.StackOverflowError
   at org.apache.commons.net.ftp.FTPFile.isDirectory(FTPFile.java:116)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:334)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 

[jira] [Commented] (VFS-437) [FTP] Program crashes when StackOverFlow Exception happens from pulling a softlinked directory that link to the directory that has the same name one level above

2012-10-04 Thread Gary D. Gregory (JIRA)

[ 
https://issues.apache.org/jira/browse/VFS-437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13469352#comment-13469352
 ] 

Gary D. Gregory commented on VFS-437:
-

The patch does break existing unit tests, which is nice :)

Can you test this for longer circular dependencies?

This patch looks to work for Vol1 - /Vol1, but what about for Vol1 - ... - 
/Vol1?

 [FTP] Program crashes when StackOverFlow Exception happens from pulling a 
 softlinked directory that link to the directory that has the same name one 
 level above 
 -

 Key: VFS-437
 URL: https://issues.apache.org/jira/browse/VFS-437
 Project: Commons VFS
  Issue Type: Bug
Affects Versions: 2.0
 Environment: java version 1.7.0_02
 Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
 Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
 Linux version 2.6.18-238.el5 (mockbu...@builder10.centos.org) (gcc version 
 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Jan 13 15:51:15 EST 2011
Reporter: Jason
Priority: Blocker
 Fix For: 2.1

 Attachments: VFS-437.diff


 With the setting below, StackOverFlow exceptions occur and server crashes
 set the builder.setUserDirlsRoot (opt, true)
 Attept to pull with:
 ftp://root:password@ip:/Vol1
 Vol directory has the following info
 lrwxrwxrwx  1 root root5 Oct  5  2007 Vol1 - /Vol1
 When it tries to look for the parent of the Vol1, it goes back to the same 
 Vol1, which causes a infinite loop that eventually creates stackoverflow 
 exception.
 The problem is inside the doGetType() method in FtpFileObject
 @Override
 protected FileType doGetType()
 throws Exception
 {
 // VFS-210
 synchronized (getFileSystem())
 {
 if (this.fileInfo == null)
 {
 getInfo(false);
 }
 if (this.fileInfo == UNKNOWN)
 {
 return FileType.IMAGINARY;
 }
 else if (this.fileInfo.isDirectory())
 {
 return FileType.FOLDER;
 }
 else if (this.fileInfo.isFile())
 {
 return FileType.FILE;
 }
 else if (this.fileInfo.isSymbolicLink())
 {
 return getLinkDestination().getType();
 }
 }
 throw new FileSystemException(vfs.provider.ftp/get-type.error, 
 getName());
 }
 It will keep hitting the else if (this.fileinfo.isSymbolicLink()) condition 
 and the fileinfo displayed is always the Vol1 under root directory.
 Exception is shown below
 java.lang.StackOverflowError
   at org.apache.commons.net.ftp.FTPFile.isDirectory(FTPFile.java:116)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:334)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 

[jira] [Commented] (VFS-437) [FTP] Program crashes when StackOverFlow Exception happens from pulling a softlinked directory that link to the directory that has the same name one level above

2012-10-04 Thread Gary D. Gregory (JIRA)

[ 
https://issues.apache.org/jira/browse/VFS-437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13469408#comment-13469408
 ] 

Gary D. Gregory commented on VFS-437:
-

Also, what about:

# doGetContentSize()
# doGetLastModifiedTime()
# doListChildrenResolved()

?


 [FTP] Program crashes when StackOverFlow Exception happens from pulling a 
 softlinked directory that link to the directory that has the same name one 
 level above 
 -

 Key: VFS-437
 URL: https://issues.apache.org/jira/browse/VFS-437
 Project: Commons VFS
  Issue Type: Bug
Affects Versions: 2.0
 Environment: java version 1.7.0_02
 Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
 Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
 Linux version 2.6.18-238.el5 (mockbu...@builder10.centos.org) (gcc version 
 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Jan 13 15:51:15 EST 2011
Reporter: Jason
Priority: Blocker
 Fix For: 2.1

 Attachments: VFS-437.diff


 With the setting below, StackOverFlow exceptions occur and server crashes
 set the builder.setUserDirlsRoot (opt, true)
 Attept to pull with:
 ftp://root:password@ip:/Vol1
 Vol directory has the following info
 lrwxrwxrwx  1 root root5 Oct  5  2007 Vol1 - /Vol1
 When it tries to look for the parent of the Vol1, it goes back to the same 
 Vol1, which causes a infinite loop that eventually creates stackoverflow 
 exception.
 The problem is inside the doGetType() method in FtpFileObject
 @Override
 protected FileType doGetType()
 throws Exception
 {
 // VFS-210
 synchronized (getFileSystem())
 {
 if (this.fileInfo == null)
 {
 getInfo(false);
 }
 if (this.fileInfo == UNKNOWN)
 {
 return FileType.IMAGINARY;
 }
 else if (this.fileInfo.isDirectory())
 {
 return FileType.FOLDER;
 }
 else if (this.fileInfo.isFile())
 {
 return FileType.FILE;
 }
 else if (this.fileInfo.isSymbolicLink())
 {
 return getLinkDestination().getType();
 }
 }
 throw new FileSystemException(vfs.provider.ftp/get-type.error, 
 getName());
 }
 It will keep hitting the else if (this.fileinfo.isSymbolicLink()) condition 
 and the fileinfo displayed is always the Vol1 under root directory.
 Exception is shown below
 java.lang.StackOverflowError
   at org.apache.commons.net.ftp.FTPFile.isDirectory(FTPFile.java:116)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:334)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 

[jira] [Commented] (VFS-437) [FTP] Program crashes when StackOverFlow Exception happens from pulling a softlinked directory that link to the directory that has the same name one level above

2012-10-04 Thread Gary D. Gregory (JIRA)

[ 
https://issues.apache.org/jira/browse/VFS-437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13469476#comment-13469476
 ] 

Gary D. Gregory commented on VFS-437:
-

I've attached a new patch that implements the same kind of logic but for more 
methods. 

Can you test this in your set up?

Also, do you see doGetChildren() as needing to check for circular links as well?

 [FTP] Program crashes when StackOverFlow Exception happens from pulling a 
 softlinked directory that link to the directory that has the same name one 
 level above 
 -

 Key: VFS-437
 URL: https://issues.apache.org/jira/browse/VFS-437
 Project: Commons VFS
  Issue Type: Bug
Affects Versions: 2.0
 Environment: java version 1.7.0_02
 Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
 Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
 Linux version 2.6.18-238.el5 (mockbu...@builder10.centos.org) (gcc version 
 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Jan 13 15:51:15 EST 2011
Reporter: Jason
Priority: Blocker
 Fix For: 2.1

 Attachments: VFS-437.diff, vfs-437-v2-gg.diff


 With the setting below, StackOverFlow exceptions occur and server crashes
 set the builder.setUserDirlsRoot (opt, true)
 Attept to pull with:
 ftp://root:password@ip:/Vol1
 Vol directory has the following info
 lrwxrwxrwx  1 root root5 Oct  5  2007 Vol1 - /Vol1
 When it tries to look for the parent of the Vol1, it goes back to the same 
 Vol1, which causes a infinite loop that eventually creates stackoverflow 
 exception.
 The problem is inside the doGetType() method in FtpFileObject
 @Override
 protected FileType doGetType()
 throws Exception
 {
 // VFS-210
 synchronized (getFileSystem())
 {
 if (this.fileInfo == null)
 {
 getInfo(false);
 }
 if (this.fileInfo == UNKNOWN)
 {
 return FileType.IMAGINARY;
 }
 else if (this.fileInfo.isDirectory())
 {
 return FileType.FOLDER;
 }
 else if (this.fileInfo.isFile())
 {
 return FileType.FILE;
 }
 else if (this.fileInfo.isSymbolicLink())
 {
 return getLinkDestination().getType();
 }
 }
 throw new FileSystemException(vfs.provider.ftp/get-type.error, 
 getName());
 }
 It will keep hitting the else if (this.fileinfo.isSymbolicLink()) condition 
 and the fileinfo displayed is always the Vol1 under root directory.
 Exception is shown below
 java.lang.StackOverflowError
   at org.apache.commons.net.ftp.FTPFile.isDirectory(FTPFile.java:116)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:334)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 

[jira] [Commented] (VFS-437) [FTP] Program crashes when StackOverFlow Exception happens from pulling a softlinked directory that link to the directory that has the same name one level above

2012-10-02 Thread Gary D. Gregory (JIRA)

[ 
https://issues.apache.org/jira/browse/VFS-437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13467637#comment-13467637
 ] 

Gary D. Gregory commented on VFS-437:
-

I'm willing to take a look at this but I do not want to spend 1/2 day setting 
it up. Can you provide step by step instructions on creating the test bed?

 [FTP] Program crashes when StackOverFlow Exception happens from pulling a 
 softlinked directory that link to the directory that has the same name one 
 level above 
 -

 Key: VFS-437
 URL: https://issues.apache.org/jira/browse/VFS-437
 Project: Commons VFS
  Issue Type: Bug
Affects Versions: 2.0
 Environment: java version 1.7.0_02
 Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
 Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
 Linux version 2.6.18-238.el5 (mockbu...@builder10.centos.org) (gcc version 
 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Jan 13 15:51:15 EST 2011
Reporter: Jason
Priority: Blocker
 Fix For: 2.1


 With the setting below, StackOverFlow exceptions occur and server crashes
 set the builder.setUserDirlsRoot (opt, true)
 Attept to pull with:
 ftp://root:password@ip:/Vol1
 Vol directory has the following info
 lrwxrwxrwx  1 root root5 Oct  5  2007 Vol1 - /Vol1
 When it tries to look for the parent of the Vol1, it goes back to the same 
 Vol1, which causes a infinite loop that eventually creates stackoverflow 
 exception.
 The problem is inside the doGetType() method in FtpFileObject
 @Override
 protected FileType doGetType()
 throws Exception
 {
 // VFS-210
 synchronized (getFileSystem())
 {
 if (this.fileInfo == null)
 {
 getInfo(false);
 }
 if (this.fileInfo == UNKNOWN)
 {
 return FileType.IMAGINARY;
 }
 else if (this.fileInfo.isDirectory())
 {
 return FileType.FOLDER;
 }
 else if (this.fileInfo.isFile())
 {
 return FileType.FILE;
 }
 else if (this.fileInfo.isSymbolicLink())
 {
 return getLinkDestination().getType();
 }
 }
 throw new FileSystemException(vfs.provider.ftp/get-type.error, 
 getName());
 }
 It will keep hitting the else if (this.fileinfo.isSymbolicLink()) condition 
 and the fileinfo displayed is always the Vol1 under root directory.
 Exception is shown below
 java.lang.StackOverflowError
   at org.apache.commons.net.ftp.FTPFile.isDirectory(FTPFile.java:116)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:334)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 

[jira] [Commented] (VFS-437) [FTP] Program crashes when StackOverFlow Exception happens from pulling a softlinked directory that link to the directory that has the same name one level above

2012-10-02 Thread Dennis Zhu (JIRA)

[ 
https://issues.apache.org/jira/browse/VFS-437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13467966#comment-13467966
 ] 

Dennis Zhu commented on VFS-437:


Here it is:

VFS-437

1. Configure the remote FTP server's local_root to be a certain directory by 
modifying vsftpd.conf, for example local_root=/Vol1. This will cause all 
users who log in to this FTP server to see /Vol1 as the root / folder.
2. Navigate to this local_root folder, and create a symbolic link with the same 
name that links to this folder. For example, we create a symlink also called 
Vol1 that links to /Vol1, so that Vol1 - /Vol1.
3. Use VFS to access this FTP server using a URL such as 
ftp://test:password@ftp.example.server/Vol1;. For example, using the following 
test code:

@Test
public void test()
throws FileSystemException {
FileSystemOptions opts = new FileSystemOptions();
FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot( opts, true );
final FileObject file = VFS.getManager().resolveFile( 
ftp://test:password@ftp.example.server/Vol1;, opts );
System.out.println( file );
for ( FileObject child : file.getChildren() ) {
System.out.println( child );
if ( child.getType() == FileType.FOLDER )
for ( FileObject child2 : child.getChildren() ) {
System.out.println( child2 );
}
}
}

This will reproduce the StackOverFlow Exception because our URL tries to 
resolve the directory /Vol1, thinking that our root directory is the / 
directory. However, what actually happens is that our URL actually will try to 
resolve /Vol1/Vol1 on the FTP file system. This is due to the fact that we 
have setUserDirIsRoot( opts, true ). Now, since resolving /Vol1 will bring us 
back to the Vol1 symbolic link itself and not the actual directory, we'll be 
infinitely trying to perform doGetType() in FtpFileObject on the symbolic link.

In summary, the StackOverFlow is guaranteed to happen when the user is in 
relative path mode (setUserDirIsRoot to true) and using a symbolic link to 
access a file or directory, with the same name as the symbolic link, on the 
file system that he doesn't have access to. This is an edge case that is only 
likly to happen when the user sets up these kind of symbolic links that he's 
not supposed to use in an FTP server. However, this case WILL crash 
applications when it comes up.

 [FTP] Program crashes when StackOverFlow Exception happens from pulling a 
 softlinked directory that link to the directory that has the same name one 
 level above 
 -

 Key: VFS-437
 URL: https://issues.apache.org/jira/browse/VFS-437
 Project: Commons VFS
  Issue Type: Bug
Affects Versions: 2.0
 Environment: java version 1.7.0_02
 Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
 Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
 Linux version 2.6.18-238.el5 (mockbu...@builder10.centos.org) (gcc version 
 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Jan 13 15:51:15 EST 2011
Reporter: Jason
Priority: Blocker
 Fix For: 2.1


 With the setting below, StackOverFlow exceptions occur and server crashes
 set the builder.setUserDirlsRoot (opt, true)
 Attept to pull with:
 ftp://root:password@ip:/Vol1
 Vol directory has the following info
 lrwxrwxrwx  1 root root5 Oct  5  2007 Vol1 - /Vol1
 When it tries to look for the parent of the Vol1, it goes back to the same 
 Vol1, which causes a infinite loop that eventually creates stackoverflow 
 exception.
 The problem is inside the doGetType() method in FtpFileObject
 @Override
 protected FileType doGetType()
 throws Exception
 {
 // VFS-210
 synchronized (getFileSystem())
 {
 if (this.fileInfo == null)
 {
 getInfo(false);
 }
 if (this.fileInfo == UNKNOWN)
 {
 return FileType.IMAGINARY;
 }
 else if (this.fileInfo.isDirectory())
 {
 return FileType.FOLDER;
 }
 else if (this.fileInfo.isFile())
 {
 return FileType.FILE;
 }
 else if (this.fileInfo.isSymbolicLink())
 {
 return getLinkDestination().getType();
 }
 }
 throw new FileSystemException(vfs.provider.ftp/get-type.error, 
 getName());
 }
 It will keep hitting the else if (this.fileinfo.isSymbolicLink()) condition 
 and the fileinfo displayed is always the Vol1 under root directory.
 Exception is shown below
 

[jira] [Commented] (VFS-437) [FTP] Program crashes when StackOverFlow Exception happens from pulling a softlinked directory that link to the directory that has the same name one level above

2012-10-02 Thread Dan Tran (JIRA)

[ 
https://issues.apache.org/jira/browse/VFS-437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13468041#comment-13468041
 ] 

Dan Tran commented on VFS-437:
--

Hi Gary, 

Dennis, Jason, and I work on the same team.  Other way to reproduce this issue 
is 

  1. use anonymous account on a linux ftp server 
  2. On your anonymous workspace create a symlink ( Vol1 to /Vol1 ). The ftp'ls 
command should show

 ftp ls -al
 200 PORT command successful. Consider using PASV.
 150 Here comes the directory listing.
 drwxr-xr-x4 004096 Oct 02 19:02 .
 drwxr-xr-x4 004096 Oct 02 19:02 ..
 lrwxrwxrwx1 00   5 Oct 02 19:02 Vol1 - /Vol1
 drwxr-xr-x2 004096 Sep 03  2009 pub
 -rw-r--r--1 00 224 Nov 09  2004 welcome.msg
 226 Directory send OK.
 ftp:385 bytes received in 0.00Seconds 385000.00Kbytes/sec.


  3. Use vfs-maven-plugin to issue the following command ( provided that you 
have access to codehaus's snapshot repository


 mvn vfs:list -DsourceId=ftp.anonymous -Dsource=ftp://your.ftp.host/Vol1


This is very edgecase, however, it crashes our server application.  


 [FTP] Program crashes when StackOverFlow Exception happens from pulling a 
 softlinked directory that link to the directory that has the same name one 
 level above 
 -

 Key: VFS-437
 URL: https://issues.apache.org/jira/browse/VFS-437
 Project: Commons VFS
  Issue Type: Bug
Affects Versions: 2.0
 Environment: java version 1.7.0_02
 Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
 Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
 Linux version 2.6.18-238.el5 (mockbu...@builder10.centos.org) (gcc version 
 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Jan 13 15:51:15 EST 2011
Reporter: Jason
Priority: Blocker
 Fix For: 2.1


 With the setting below, StackOverFlow exceptions occur and server crashes
 set the builder.setUserDirlsRoot (opt, true)
 Attept to pull with:
 ftp://root:password@ip:/Vol1
 Vol directory has the following info
 lrwxrwxrwx  1 root root5 Oct  5  2007 Vol1 - /Vol1
 When it tries to look for the parent of the Vol1, it goes back to the same 
 Vol1, which causes a infinite loop that eventually creates stackoverflow 
 exception.
 The problem is inside the doGetType() method in FtpFileObject
 @Override
 protected FileType doGetType()
 throws Exception
 {
 // VFS-210
 synchronized (getFileSystem())
 {
 if (this.fileInfo == null)
 {
 getInfo(false);
 }
 if (this.fileInfo == UNKNOWN)
 {
 return FileType.IMAGINARY;
 }
 else if (this.fileInfo.isDirectory())
 {
 return FileType.FOLDER;
 }
 else if (this.fileInfo.isFile())
 {
 return FileType.FILE;
 }
 else if (this.fileInfo.isSymbolicLink())
 {
 return getLinkDestination().getType();
 }
 }
 throw new FileSystemException(vfs.provider.ftp/get-type.error, 
 getName());
 }
 It will keep hitting the else if (this.fileinfo.isSymbolicLink()) condition 
 and the fileinfo displayed is always the Vol1 under root directory.
 Exception is shown below
 java.lang.StackOverflowError
   at org.apache.commons.net.ftp.FTPFile.isDirectory(FTPFile.java:116)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:334)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 

[jira] [Commented] (VFS-437) [FTP] Program crashes when StackOverFlow Exception happens from pulling a softlinked directory that link to the directory that has the same name one level above

2012-10-02 Thread Dennis Zhu (JIRA)

[ 
https://issues.apache.org/jira/browse/VFS-437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13468268#comment-13468268
 ] 

Dennis Zhu commented on VFS-437:


Here's a proposed fix for the problem in FtpFileObject.java under the method 
doGetType() inside the if block that checks for the type of this.fileInfo:

else if ( this.fileInfo.isSymbolicLink() ) {
FileObject linkDest = getLinkDestination();

// VFS-437: We need to check if the symbolic link links back to 
the symbolic link itself
if ( linkDest.getName().getPathDecoded().equals( 
this.getName().getPathDecoded() ) ) {

// If the symbolic link links back to itself, treat it as 
an imaginary file to prevent following
// this link. If the user tries to access the link as a 
file or directory, the user will end up with
// a FileSystemException warning that the file cannot be 
accessed. This is to prevent the infinite
// call back to doGetType() to prevent the StackOverFlow
return FileType.IMAGINARY;

}
return linkDest.getType();
}

The idea here is that if we detect this kind of a bad symbolic link, we return 
the type of the link as a FileType.IMAGINARY file, which means it cannot be 
accessed by any means through VFS. This will prevent the user from trying to 
open the link or navigate into the link as a directory.

svndiff report and patch file comparing FtpFileObject.java is also attached

 [FTP] Program crashes when StackOverFlow Exception happens from pulling a 
 softlinked directory that link to the directory that has the same name one 
 level above 
 -

 Key: VFS-437
 URL: https://issues.apache.org/jira/browse/VFS-437
 Project: Commons VFS
  Issue Type: Bug
Affects Versions: 2.0
 Environment: java version 1.7.0_02
 Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
 Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
 Linux version 2.6.18-238.el5 (mockbu...@builder10.centos.org) (gcc version 
 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Jan 13 15:51:15 EST 2011
Reporter: Jason
Priority: Blocker
 Fix For: 2.1

 Attachments: FtpFileObject_patch, FtpFileObject_svndiff.htm


 With the setting below, StackOverFlow exceptions occur and server crashes
 set the builder.setUserDirlsRoot (opt, true)
 Attept to pull with:
 ftp://root:password@ip:/Vol1
 Vol directory has the following info
 lrwxrwxrwx  1 root root5 Oct  5  2007 Vol1 - /Vol1
 When it tries to look for the parent of the Vol1, it goes back to the same 
 Vol1, which causes a infinite loop that eventually creates stackoverflow 
 exception.
 The problem is inside the doGetType() method in FtpFileObject
 @Override
 protected FileType doGetType()
 throws Exception
 {
 // VFS-210
 synchronized (getFileSystem())
 {
 if (this.fileInfo == null)
 {
 getInfo(false);
 }
 if (this.fileInfo == UNKNOWN)
 {
 return FileType.IMAGINARY;
 }
 else if (this.fileInfo.isDirectory())
 {
 return FileType.FOLDER;
 }
 else if (this.fileInfo.isFile())
 {
 return FileType.FILE;
 }
 else if (this.fileInfo.isSymbolicLink())
 {
 return getLinkDestination().getType();
 }
 }
 throw new FileSystemException(vfs.provider.ftp/get-type.error, 
 getName());
 }
 It will keep hitting the else if (this.fileinfo.isSymbolicLink()) condition 
 and the fileinfo displayed is always the Vol1 under root directory.
 Exception is shown below
 java.lang.StackOverflowError
   at org.apache.commons.net.ftp.FTPFile.isDirectory(FTPFile.java:116)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:334)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 

[jira] [Commented] (VFS-437) [FTP] Program crashes when StackOverFlow Exception happens from pulling a softlinked directory that link to the directory that has the same name one level above

2012-09-28 Thread Dennis Zhu (JIRA)

[ 
https://issues.apache.org/jira/browse/VFS-437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13466076#comment-13466076
 ] 

Dennis Zhu commented on VFS-437:


There is more to this problem:

It will arise when the FTP's local_root directory is also set to Vol1

so in the vsftpd.conf file, we have local_root=/Vol1/

Inside this /Vol1/ folder, we have a symlink called Vol1 that links back to 
/Vol1

This causes the getInfo( boolean flush) method in FtpFileObject to have 
problems at the lines:

if ( parent != null ) {
newFileInfo = parent.getChildFile( UriParser.decode( 
getName().getBaseName() ), flush );
}

Parent here is supposed to be / and we are looking for child file /Vol1, 
but getChildFile calls doGetChildren which instantiantiates another FtpClient 
object, and this object is looking at the local_root /Vol1 instead of looking 
at the / directory.

 [FTP] Program crashes when StackOverFlow Exception happens from pulling a 
 softlinked directory that link to the directory that has the same name one 
 level above 
 -

 Key: VFS-437
 URL: https://issues.apache.org/jira/browse/VFS-437
 Project: Commons VFS
  Issue Type: Bug
Affects Versions: 2.0
 Environment: java version 1.7.0_02
 Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
 Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
 Linux version 2.6.18-238.el5 (mockbu...@builder10.centos.org) (gcc version 
 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Jan 13 15:51:15 EST 2011
Reporter: Jason
Priority: Blocker
 Fix For: 2.1


 With the setting below, StackOverFlow exceptions occur and server crashes
 set the builder.setUserDirlsRoot (opt, true)
 Attept to pull with:
 ftp://root:password@ip:/Vol1
 Vol directory has the following info
 lrwxrwxrwx  1 root root5 Oct  5  2007 Vol1 - /Vol1
 When it tries to look for the parent of the Vol1, it goes back to the same 
 Vol1, which causes a infinite loop that eventually creates stackoverflow 
 exception.
 The problem is inside the doGetType() method in FtpFileObject
 @Override
 protected FileType doGetType()
 throws Exception
 {
 // VFS-210
 synchronized (getFileSystem())
 {
 if (this.fileInfo == null)
 {
 getInfo(false);
 }
 if (this.fileInfo == UNKNOWN)
 {
 return FileType.IMAGINARY;
 }
 else if (this.fileInfo.isDirectory())
 {
 return FileType.FOLDER;
 }
 else if (this.fileInfo.isFile())
 {
 return FileType.FILE;
 }
 else if (this.fileInfo.isSymbolicLink())
 {
 return getLinkDestination().getType();
 }
 }
 throw new FileSystemException(vfs.provider.ftp/get-type.error, 
 getName());
 }
 It will keep hitting the else if (this.fileinfo.isSymbolicLink()) condition 
 and the fileinfo displayed is always the Vol1 under root directory.
 Exception is shown below
 java.lang.StackOverflowError
   at org.apache.commons.net.ftp.FTPFile.isDirectory(FTPFile.java:116)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:334)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 

[jira] [Commented] (VFS-437) [FTP] Program crashes when StackOverFlow Exception happens from pulling a softlinked directory that link to the directory that has the same name one level above

2012-09-19 Thread Jason (JIRA)

[ 
https://issues.apache.org/jira/browse/VFS-437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13459111#comment-13459111
 ] 

Jason commented on VFS-437:
---

On the remote ftp server (I used CentOs distribution)
1. Create a Voll directory under file system so the path is /Vol
2. Create a Vol1 directory under the user's home directory so the path is 
/user/Vol1
3. Make the Vol1 under step two soft link to the Vol1 in step one, so ls -al 
would show the following 
lrwxrwxrwx 1 root root 5 Oct 5 2007 Vol1 - /Vol1

I used the test case you've written, I can actually reproduce the exception 
also. The only difference is my ftp server is not a localhost.

@Test
public void test() throws FileSystemException
{
FileSystemOptions opts = new FileSystemOptions();
FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true);
final FileObject file = 
VFS.getManager().resolveFile(ftp://test1:test1@remoteIp/Vol1;, opts);
System.out.println(file);
for (FileObject child : file.getChildren())
{
System.out.println(child);
for (FileObject child2 : child.getChildren())
{
System.out.println(child2);
}
}
}

I reproduce this issue with scenario of Windows 7 and Linux(Centos) trying to 
access a Linux ftp remote server.

 [FTP] Program crashes when StackOverFlow Exception happens from pulling a 
 softlinked directory that link to the directory that has the same name one 
 level above 
 -

 Key: VFS-437
 URL: https://issues.apache.org/jira/browse/VFS-437
 Project: Commons VFS
  Issue Type: Bug
Affects Versions: 2.0
 Environment: java version 1.7.0_02
 Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
 Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
 Linux version 2.6.18-238.el5 (mockbu...@builder10.centos.org) (gcc version 
 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Jan 13 15:51:15 EST 2011
Reporter: Jason
Priority: Blocker
 Fix For: 2.1


 With the setting below, StackOverFlow exceptions occur and server crashes
 set the builder.setUserDirlsRoot (opt, true)
 Attept to pull with:
 ftp://root:password@ip:/Vol1
 Vol directory has the following info
 lrwxrwxrwx  1 root root5 Oct  5  2007 Vol1 - /Vol1
 When it tries to look for the parent of the Vol1, it goes back to the same 
 Vol1, which causes a infinite loop that eventually creates stackoverflow 
 exception.
 The problem is inside the doGetType() method in FtpFileObject
 @Override
 protected FileType doGetType()
 throws Exception
 {
 // VFS-210
 synchronized (getFileSystem())
 {
 if (this.fileInfo == null)
 {
 getInfo(false);
 }
 if (this.fileInfo == UNKNOWN)
 {
 return FileType.IMAGINARY;
 }
 else if (this.fileInfo.isDirectory())
 {
 return FileType.FOLDER;
 }
 else if (this.fileInfo.isFile())
 {
 return FileType.FILE;
 }
 else if (this.fileInfo.isSymbolicLink())
 {
 return getLinkDestination().getType();
 }
 }
 throw new FileSystemException(vfs.provider.ftp/get-type.error, 
 getName());
 }
 It will keep hitting the else if (this.fileinfo.isSymbolicLink()) condition 
 and the fileinfo displayed is always the Vol1 under root directory.
 Exception is shown below
 java.lang.StackOverflowError
   at org.apache.commons.net.ftp.FTPFile.isDirectory(FTPFile.java:116)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:334)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   

[jira] [Commented] (VFS-437) [FTP] Program crashes when StackOverFlow Exception happens from pulling a softlinked directory that link to the directory that has the same name one level above

2012-09-18 Thread Gary D. Gregory (JIRA)

[ 
https://issues.apache.org/jira/browse/VFS-437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13458338#comment-13458338
 ] 

Gary D. Gregory commented on VFS-437:
-

Hello Jason,

Can you give more details please?

This works for me:

{code:java}
public class Vfs437TestCase
{

/**
 * On Windows 7:
 * 
 * md /Vol1
 * 
 * cd /Vol1
 * 
 * mklink /D Vol1 \Vol1
 * 
 * @throws FileSystemException
 */
@Test
public void test() throws FileSystemException
{
FileSystemOptions opts = new FileSystemOptions();
FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true);
final FileObject file = 
VFS.getManager().resolveFile(ftp://test:zing1@localhost/Vol1;, opts);
System.out.println(file);
for (FileObject child : file.getChildren())
{
System.out.println(child);
for (FileObject child2 : child.getChildren())
{
System.out.println(child2);
}
}
}
}
{code}

I am using FileZilla as a test server locally.

 [FTP] Program crashes when StackOverFlow Exception happens from pulling a 
 softlinked directory that link to the directory that has the same name one 
 level above 
 -

 Key: VFS-437
 URL: https://issues.apache.org/jira/browse/VFS-437
 Project: Commons VFS
  Issue Type: Bug
Affects Versions: 2.0
 Environment: java version 1.7.0_02
 Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
 Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
 Linux version 2.6.18-238.el5 (mockbu...@builder10.centos.org) (gcc version 
 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Jan 13 15:51:15 EST 2011
Reporter: Jason
Priority: Blocker
 Fix For: 2.1


 With the setting below, StackOverFlow exceptions occur and server crashes
 set the builder.setUserDirlsRoot (opt, true)
 Attept to pull with:
 ftp://root:password@ip:/Vol1
 Vol directory has the following info
 lrwxrwxrwx  1 root root5 Oct  5  2007 Vol1 - /Vol1
 When it tries to look for the parent of the Vol1, it goes back to the same 
 Vol1, which causes a infinite loop that eventually creates stackoverflow 
 exception.
 The problem is inside the doGetType() method in FtpFileObject
 @Override
 protected FileType doGetType()
 throws Exception
 {
 // VFS-210
 synchronized (getFileSystem())
 {
 if (this.fileInfo == null)
 {
 getInfo(false);
 }
 if (this.fileInfo == UNKNOWN)
 {
 return FileType.IMAGINARY;
 }
 else if (this.fileInfo.isDirectory())
 {
 return FileType.FOLDER;
 }
 else if (this.fileInfo.isFile())
 {
 return FileType.FILE;
 }
 else if (this.fileInfo.isSymbolicLink())
 {
 return getLinkDestination().getType();
 }
 }
 throw new FileSystemException(vfs.provider.ftp/get-type.error, 
 getName());
 }
 It will keep hitting the else if (this.fileinfo.isSymbolicLink()) condition 
 and the fileinfo displayed is always the Vol1 under root directory.
 Exception is shown below
 java.lang.StackOverflowError
   at org.apache.commons.net.ftp.FTPFile.isDirectory(FTPFile.java:116)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:334)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 

[jira] [Commented] (VFS-437) [FTP] Program crashes when StackOverFlow Exception happens from pulling a softlinked directory that link to the directory that has the same name one level above

2012-09-18 Thread Jason (JIRA)

[ 
https://issues.apache.org/jira/browse/VFS-437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13458342#comment-13458342
 ] 

Jason commented on VFS-437:
---

The ftp server should be linux system

 [FTP] Program crashes when StackOverFlow Exception happens from pulling a 
 softlinked directory that link to the directory that has the same name one 
 level above 
 -

 Key: VFS-437
 URL: https://issues.apache.org/jira/browse/VFS-437
 Project: Commons VFS
  Issue Type: Bug
Affects Versions: 2.0
 Environment: java version 1.7.0_02
 Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
 Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
 Linux version 2.6.18-238.el5 (mockbu...@builder10.centos.org) (gcc version 
 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Thu Jan 13 15:51:15 EST 2011
Reporter: Jason
Priority: Blocker
 Fix For: 2.1


 With the setting below, StackOverFlow exceptions occur and server crashes
 set the builder.setUserDirlsRoot (opt, true)
 Attept to pull with:
 ftp://root:password@ip:/Vol1
 Vol directory has the following info
 lrwxrwxrwx  1 root root5 Oct  5  2007 Vol1 - /Vol1
 When it tries to look for the parent of the Vol1, it goes back to the same 
 Vol1, which causes a infinite loop that eventually creates stackoverflow 
 exception.
 The problem is inside the doGetType() method in FtpFileObject
 @Override
 protected FileType doGetType()
 throws Exception
 {
 // VFS-210
 synchronized (getFileSystem())
 {
 if (this.fileInfo == null)
 {
 getInfo(false);
 }
 if (this.fileInfo == UNKNOWN)
 {
 return FileType.IMAGINARY;
 }
 else if (this.fileInfo.isDirectory())
 {
 return FileType.FOLDER;
 }
 else if (this.fileInfo.isFile())
 {
 return FileType.FILE;
 }
 else if (this.fileInfo.isSymbolicLink())
 {
 return getLinkDestination().getType();
 }
 }
 throw new FileSystemException(vfs.provider.ftp/get-type.error, 
 getName());
 }
 It will keep hitting the else if (this.fileinfo.isSymbolicLink()) condition 
 and the fileinfo displayed is always the Vol1 under root directory.
 Exception is shown below
 java.lang.StackOverflowError
   at org.apache.commons.net.ftp.FTPFile.isDirectory(FTPFile.java:116)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:334)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at 
 org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
   at 
 org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:344)
   at