From owner-freebsd-java Fri Feb 7 11:27:35 2003 Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C3C6837B401 for ; Fri, 7 Feb 2003 11:27:33 -0800 (PST) Received: from mgr2.xmission.com (mgr2.xmission.com [198.60.22.202]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5C7D543FCB for ; Fri, 7 Feb 2003 11:27:32 -0800 (PST) (envelope-from glewis@eyesbeyond.com) Received: from mail by mgr2.xmission.com with spam-scanned (Exim 3.35 #1) id 18hE9O-0003pW-02 for freebsd-java@freebsd.org; Fri, 07 Feb 2003 12:27:02 -0700 Received: from [207.135.128.145] (helo=misty.eyesbeyond.com) by mgr2.xmission.com with esmtp (Exim 3.35 #1) id 18hE9M-0003nZ-02; Fri, 07 Feb 2003 12:27:01 -0700 Received: (from glewis@localhost) by misty.eyesbeyond.com (8.11.6/8.11.6) id h17JQtd20278; Sat, 8 Feb 2003 05:56:55 +1030 (CST) (envelope-from glewis@eyesbeyond.com) X-Authentication-Warning: misty.eyesbeyond.com: glewis set sender to glewis@eyesbeyond.com using -f Date: Sat, 8 Feb 2003 05:56:55 +1030 From: Greg Lewis To: Brent Verner Cc: freebsd-java@FreeBSD.ORG Subject: Re: [patch] daemonctl.c modified to use JAVA_HOME environment variable Message-ID: <20030208055654.A20219@misty.eyesbeyond.com> References: <20030207163217.GA99329@rcfile.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20030207163217.GA99329@rcfile.org>; from brent@rcfile.org on Fri, Feb 07, 2003 at 11:32:17AM -0500 X-Spam-Status: No, hits=-3.5 required=8.0 tests=IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, SIGNATURE_SHORT_DENSE,SPAM_PHRASE_00_01,USER_AGENT, USER_AGENT_MUTT,X_AUTH_WARNING version=2.43 X-Spam-Level: Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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