This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: MAXPATHLEN usage - PR21821
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Wed, 01 Jun 2005 19:01:05 -0400
- Subject: Patch: MAXPATHLEN usage - PR21821
This is a partial fix for PR21821 - it fixes the issue for
natFileChannelPosix.cc but not natFilePosix.cc, which is a bit trickier.
I actually checked this in yesterday but forgot to post the patch. Here
it is.
Bryce
2005-05-30 Bryce McKinlay <mckinlay@redhat.com>
PR libgcj/21821
* gnu/java/nio/channels/natFileChannelPosix.cc (open): Don't use
MAXPATHLEN. Format exception message using a StringBuffer instead.
Index: gnu/java/nio/channels/natFileChannelPosix.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/channels/natFileChannelPosix.cc,v
retrieving revision 1.6
diff -u -r1.6 natFileChannelPosix.cc
--- gnu/java/nio/channels/natFileChannelPosix.cc 12 Nov 2004 19:15:27 -0000 1.6
+++ gnu/java/nio/channels/natFileChannelPosix.cc 30 May 2005 16:01:38 -0000
@@ -37,6 +37,7 @@
#include <java/lang/NullPointerException.h>
#include <java/lang/System.h>
#include <java/lang/String.h>
+#include <java/lang/StringBuffer.h>
#include <java/lang/Thread.h>
#include <java/nio/ByteBuffer.h>
#include <java/nio/MappedByteBufferImpl.h>
@@ -168,13 +169,13 @@
}
if (fd == -1)
{
- char msg[MAXPATHLEN + 200];
// We choose the formatting here for JDK compatibility, believe
// it or not.
- sprintf (msg, "%.*s (%.*s)",
- MAXPATHLEN + 150, buf,
- 40, strerror (errno));
- throw new ::java::io::FileNotFoundException (JvNewStringLatin1 (msg));
+ ::java::lang::StringBuffer *msg = new ::java::lang::StringBuffer (path);
+ msg->append (JvNewStringUTF (" ("));
+ msg->append (JvNewStringUTF (strerror (errno)));
+ msg->append (JvNewStringUTF (")"));
+ throw new ::java::io::FileNotFoundException (msg->toString ());
}
_Jv_platform_close_on_exec (fd);