Menu

#1 FileUploadServlet is not IPv6-compatible

open
nobody
None
5
2007-09-21
2007-09-21
No

When using the org.cafesip.gwtcomp.server.FileUploadServlet class on an IPv6-enabled system, file uploads may not work correctly.

The problem is on line 212 of FileUploadServlet.java (from v0.0.2b):

File tempf = File.createTempFile(request.getRemoteAddr()
+ "-" + item.getFieldName() + "-", "");

For example, if you're using localhost, the request.getRemoteAddr() call will return "0:0:0:0:0:0:0:1" (the IPv6 equivalent of 127.0.0.1). On the Windows NTFS filesystem (and probably on other filesystems as well), ":" is an invalid character to have in a filename. The call will fail with the following exception:

java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.checkAndCreate(File.java:1345)
at java.io.File.createTempFile(File.java:1434)
at java.io.File.createTempFile(File.java:1471)
at org.cafesip.gwtcomp.server.FileUploadServlet.doPost(FileUploadServlet.java:212)
...

Perhaps a good solution would be to convert the remote address to hex first.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.