Due to passing the wrong length to strncmp, any key in %ENV whose
beginning matched something in the C environ array would get conflated
with it. In other words, $ENV{PATH} and $ENV{PATHOLOGICAL} would both be
treated as $ENV{PATH}. The attached patch fixes this and is against
bleadperl but relevant to 5.6 and later. Thanks to Greg Snow for the bug
report.

--- vms/vms.c_orig      Sun Dec  7 15:36:04 2003
+++ vms/vms.c   Thu Dec 11 10:21:13 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];
@@ -733,8 +734,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;

Reply via email to