Issue Details (XML | Word | Printable)

Key: NET-201
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Sebb
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Commons Net

UnixFTPEntryParser does not handle character/block special devices properly

Created: 09/Mar/08 08:20 PM   Updated: 16/Mar/08 09:46 PM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0, 1.5

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works FTPParse_specialDevices.patch 2008-03-16 01:40 PM Martin Oberhuber 2 kB
Issue Links:
Reference
 

Resolution Date: 16/Mar/08 08:18 PM


 Description  « Hide
The following is a valid entry from a FreeBSD system:

crw-r----- 1 root kmem 0, 27 Jan 30 11:42 kmem

This causes a parse error, because the regular expression does not allow for the major and minor device numbers.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Martin Oberhuber added a comment - 16/Mar/08 01:21 PM
We found the same issue on a Solaris server a while back, and resorted to a workaround of not showing the file (because we reckoned that users cannot do much with a character special device anyways).

The point is that Commons Net throws a parse exception, because it expects a single number ("size") where it finds the device numbers ("0, 27"). What we did is catch the exception and ignore the file. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=197105

A possible fix should be in UnixFTPEntryParser.java line 94, replace
+ "(\\d+)
s+"
by
+ "(\\d+(?:,\\s*\\d+)?)
s+"

This will result in a valid FTPFile with size=0 and valid raw listing attached. I do not think that it is worth changing the FTPFile API to have separate fields for the major and minor numbers.


Martin Oberhuber added a comment - 16/Mar/08 01:40 PM
Attached patch + unittests.
May I vote for this to be applied for the upcoming 1.5 release?

Rory Winston added a comment - 16/Mar/08 08:03 PM
Martin

That sounds reasonable to me - I'll apply to 1.5 and 2.0 now and then we can verify and test.


Rory Winston added a comment - 16/Mar/08 08:18 PM
Applied.

Sebb added a comment - 16/Mar/08 09:46 PM
Seems to be similar to NET-25