Patch: FYI: Fix for PR libgcj/5064
Tom Tromey
tromey@redhat.com
Thu Nov 1 23:16:00 GMT 2001
This fixes PR 5064. I just removed all mention of stdio, as it was
easy and I prefer that anyhow.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
Fix for PR libgcj/5064.
* java/lang/natClassLoader.cc: Don't include stdio.h.
(_Jv_RegisterClassHookDefault): Don't use snprintf.
Index: java/lang/natClassLoader.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natClassLoader.cc,v
retrieving revision 1.43
diff -u -r1.43 natClassLoader.cc
--- java/lang/natClassLoader.cc 2001/11/26 06:40:06 1.43
+++ java/lang/natClassLoader.cc 2001/12/11 03:50:36
@@ -14,7 +14,6 @@
#include <stdlib.h>
#include <string.h>
-#include <stdio.h>
#include <gcj/cni.h>
#include <jvm.h>
@@ -463,9 +462,13 @@
{
// If you get this, it means you have the same class in two
// different libraries.
+#define TEXT "Duplicate class registration: "
+ // We size-limit MESSAGE so that you can't trash the stack.
char message[200];
- snprintf (&message[0], 200, "Duplicate class registration: %s",
- klass->name->data);
+ strcpy (message, TEXT);
+ strncpy (message + sizeof (TEXT) - 1, klass->name->data,
+ sizeof (message) - sizeof (TEXT));
+ message[sizeof (message) - 1] = '\0';
if (! gcj::runtimeInitialized)
JvFail (message);
else
More information about the Java-patches
mailing list