Craig A. Berry wrote:
At 12:12 PM -0700 12/6/03, Snow, Greg wrote:
$ENV{PATHanything} is returning $ENV{PATH} when PATHanything is not defined.
This behavior can be observed with HOME and TERM, as well as PATH.
<big snip>
Does this problem still exist in later versions?
It's a definite bug, Greg. Thanks for the thorough report. I've taken a quick look at the code and don't see anything obvious, so this will take some slogging to fix.
Not all that much slogging. It was a silly case of comparing two strings with strncmp, but passing the length of what turned out to be the shorter of the two strings. So, for example, PATH and PATHETIC would be considered a match because only the first four bytes would be compared. Only environment variables contained in the CRTL's environ array were affected by the bug.
The attached patch should take care of it,though I'll kick it around a little more before getting it into bleadperl. I can't promise when it will get into a production release, but there's a good chance it will make it into 5.8.3, due next month.
Here's my test to show that it worked, with no relevant logical names defined:
$ type testenv.pl
my @s=('PATH','PATHOLOGICAL','HOME','HOMEOPATHY');
for my $env (@s) {
print qq/\$ENV{$env} = $ENV{$env}\n/;
}___before patch:
$ perl testenv.pl
$ENV{PATH} = d0:[craig.perl]
$ENV{PATHOLOGICAL} = d0:[craig.perl]
$ENV{HOME} = d0:[craig]
$ENV{HOMEOPATHY} = d0:[craig]___ after patch:
$ perl testenv.pl
$ENV{PATH} = d0:[craig.perl]
$ENV{PATHOLOGICAL} =
$ENV{HOME} = d0:[craig]
$ENV{HOMEOPATHY} =--- vms/vms.c;-0 Fri Jul 4 00:05:00 2003
+++ vms/vms.c Sun Dec 7 13:07:21 2003
@@ -222,6 +222,7 @@
retsts = SS$_NOLOGNAM;
for (i = 0; environ[i]; i++) {
if ((eq = strchr(environ[i],'=')) &&
+ lnmdsc.dsc$w_length == (eq - environ[i]) &&
!strncmp(environ[i],uplnm,eq - environ[i])) {
eq++;
for (eqvlen = 0; eq[eqvlen]; eqvlen++) eqv[eqvlen] = eq[eqvlen];
@@ -728,8 +729,9 @@
for (curtab = 0; tabvec[curtab]; curtab++) {
if (!ivenv && !str$case_blind_compare(tabvec[curtab],&crtlenv)) {
int i;
- for (i = 0; environ[i]; i++) { /* Iff it's an environ elt, reset */
+ for (i = 0; environ[i]; i++) { /* If it's an environ elt, reset */
if ((cp1 = strchr(environ[i],'=')) &&
+ lnmdsc.dsc$w_length == (cp1 - environ[i]) &&
!strncmp(environ[i],lnm,cp1 - environ[i])) {
#ifdef HAS_SETENV
return setenv(lnm,"",1) ? vaxc$errno : 0;
