This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: crash on GCJ_PROPERTIES="foo=" program
- From: Paul Bolle <pebolle at tiscali dot nl>
- To: java-patches at gcc dot gnu dot org
- Date: Sat, 26 Feb 2005 02:55:20 +0100
- Subject: Re: crash on GCJ_PROPERTIES="foo=" program
- References: <1109382121.4858.33.camel@compaq6560nl.thuisdomein>
0) This is more of a bug report then a patch. (I do hope this is the
correct list to report it. Otherwise I'll gladly forward this message to
gcc-patches@gcc.gnu.org or somewhere else.)
1) I've been playing with gcj recently (as included in gcc-3.4.2, in the
version shipped with Fedora Core 3).
2) I noticed that programs compiled by gcj would segfault when given a
GCJ_PROPERTIES environment variable with an empty value, for example:
GCJ_PROPERTIES="foo=" program
3) Looking at the code of libjava/prims.cc I noticed next_property_value
doesn't seem to handle the length of an empty (zero length) value
correctly. In that case it seems to reuse the length of the key part of
that key/value pair. I guess that this might cause a crash (when null
terminating the key/value pairs later). Please find attached a (trivial)
patch, written on that idea.
4) However, I didn't manage to test this patch as recompiling etc. gcc
and friends ended in a "/usr/bin/ld: Argument list too long" (after
which I gave up my attempt at correcting this myself). But maybe someone
else might like to review my analysis and maybe even test my patch.
5) Well, at least you have a bug report now ...
Kind regards,
Paul Bolle
--- libjava/prims.cc.oud 2005-02-26 00:27:53.282039752 +0100
+++ libjava/prims.cc 2005-02-26 00:42:50.913579016 +0100
@@ -779,6 +779,7 @@
next_property_value (char *s, size_t *length)
{
size_t l = 0;
+ *length = 0;
JvAssert (s);