This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch to use concat instead of xmalloc/sprintf for JAVA dir


 > From: Richard Henderson <rth@redhat.com>
 > 
 > On Sun, Apr 22, 2001 at 08:11:05AM -0400, Kaveh R. Ghazi wrote:
 > > The xmalloc length calculates enough space for the two strings, the
 > > "-f" and the "=" (i.e. +3) but not for the trailing NULL.
 > 
 > Actually, it appears to be ok:
 > 
 > > -	  sprintf (patharg, "-f%s=%s", argv[i]+1, argv[i+1]);
 > 					      ^^
 > 
 > It would have been clearer with that +1 in the strlen argument 
 > as well, with an additional +1 to the constant.
 > 
 > Anyhow, concat is the Correct solution.
 > r~

You're right, it does strlen(argv[i]) and prints argv[i]+1.  Bleah.
It doesn't appear to overrun the buffer, but its very obfuscated. :-)

Unless someone objects by this evening, I'll install the concat on the
branch to clarify it for future eyeballs.

		--Kaveh
--
Kaveh R. Ghazi			Engagement Manager / Project Services
ghazi@caip.rutgers.edu		Qwest Internet Solutions


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]