From owner-p4-projects@FreeBSD.ORG Mon Jun 26 05:21:04 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C8FFF16A409; Mon, 26 Jun 2006 05:21:04 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A4A0E16A402 for ; Mon, 26 Jun 2006 05:21:04 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 91D5943DB8 for ; Mon, 26 Jun 2006 05:21:01 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5Q5L1nJ019195 for ; Mon, 26 Jun 2006 05:21:01 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5Q5L1OH019192 for perforce@freebsd.org; Mon, 26 Jun 2006 05:21:01 GMT (envelope-from jb@freebsd.org) Date: Mon, 26 Jun 2006 05:21:01 GMT Message-Id: <200606260521.k5Q5L1OH019192@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 100021 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jun 2006 05:21:05 -0000 http://perforce.freebsd.org/chv.cgi?CH=100021 Change 100021 by jb@jb_freebsd2 on 2006/06/26 05:20:36 Remove the length limitation on kernel getenv() strings. The sx lock allows a malloc while the lock is held, so why not simplify the code and avoid copying the string to a temporary (size limited) string. This allows large kenv strings to be passed from the boot loader. The length limitation still applies in kenv(1) when setting a string. I think it should be removed from there too. It's a pretty silly limit in this day and age when we often have gobs of memory. kenv(1) has no difficulty reporting the long strings. This is required so that the anonymous enablings can be passed to the kernel from the boot loader. Affected files ... .. //depot/projects/dtrace/src/sys/kern/kern_environment.c#2 edit Differences ... ==== //depot/projects/dtrace/src/sys/kern/kern_environment.c#2 (text+ko) ==== @@ -283,7 +283,6 @@ char * getenv(const char *name) { - char buf[KENV_MNAMELEN + 1 + KENV_MVALLEN + 1]; char *ret, *cp; int len; @@ -291,11 +290,10 @@ sx_slock(&kenv_lock); cp = _getenv_dynamic(name, NULL); if (cp != NULL) { - strcpy(buf, cp); + len = strlen(cp) + 1; + ret = malloc(len, M_KENV, M_WAITOK); + strcpy(ret, cp); sx_sunlock(&kenv_lock); - len = strlen(buf) + 1; - ret = malloc(len, M_KENV, M_WAITOK); - strcpy(ret, buf); } else { sx_sunlock(&kenv_lock); ret = NULL;