Date: Mon, 26 Jun 2006 05:21:01 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 100021 for review Message-ID: <200606260521.k5Q5L1OH019192@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606260521.k5Q5L1OH019192>