Date: Sat, 8 Feb 2003 05:56:55 +1030 From: Greg Lewis <glewis@eyesbeyond.com> To: Brent Verner <brent@rcfile.org> Cc: freebsd-java@FreeBSD.ORG Subject: Re: [patch] daemonctl.c modified to use JAVA_HOME environment variable Message-ID: <20030208055654.A20219@misty.eyesbeyond.com> In-Reply-To: <20030207163217.GA99329@rcfile.org>; from brent@rcfile.org on Fri, Feb 07, 2003 at 11:32:17AM -0500 References: <20030207163217.GA99329@rcfile.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Feb 07, 2003 at 11:32:17AM -0500, Brent Verner wrote: > The attached patch modified the daemonctl.c program to use JAVA_HOME > if set in the environment. > > @@ -71,7 +75,16 @@ > > /* Declare variables, like all other good ANSI C programs do :) */ > char *argument; > - > + > + /* use JAVA_HOME environemt variable if set */ > + char* _java_home = getenv("JAVA_HOME"); > + if( _java_home != NULL && strcmp("",_java_home) != 0 ){ > + /* TODO: verify that java_prog would exist before overriding the default */ > + strncpy(java_home,_java_home,PATH_MAX-1); > + snprintf(java_prog,PATH_MAX-1,"%s/%%JAVA_CMD%%",_java_home); > + using_java_home_env = 1; > + } > + Just some minor feedback. I don't think this change is safe. If _java_home is too long to fit then java_home won't get null terminated. I suggest trying strlcpy instead. You might want to think about using strlcat instead of snprintf too, and adding some checking for overflow (and appropriate error handling if it occurs). -- Greg Lewis Email : glewis@eyesbeyond.com Eyes Beyond Web : http://www.eyesbeyond.com Information Technology FreeBSD : glewis@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030208055654.A20219>