CF9中的错误:由其他键引用和覆盖的唯一结构键的值

Gin*_*Doe 5 coldfusion

我们遇到了CF9的严重问题,其中某些结构键的值可以被其他键引用,尽管其他键从未被设置.请参阅以下示例:

编辑:看起来它不仅仅是我们的服务器吃的东西.这是Adobe错误跟踪票81884:http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#bugId=81884 .

编辑:正如已经指出的,Adobe推出了修复程序:http://kb2.adobe.com/cps/825/cpsid_82547.html

修补程序摘要指出,他们正在比较变量名称的哈希值而不是文字值,以获得速度.我不知道这会如何加快速度,但名称冲突的机会(尤其是较短名称)应该是显而易见的.至少他们很快纠正了.

<cfset a = { AO = "foo" } />
<cfset b = { AO = "foo", B0 = "bar" } />

<cfoutput>
The following should throw an error. Instead both keys refer to the same value.
<br />Struct a: <cfdump var="#a#" />
<br />a.AO: #a.AO#
<br />a.B0: #a.B0#
<hr />
The following should show a struct with 2 distinct keys and values. Instead it contains a single key, "AO", with a value of "bar".
<br />Struct b: <cfdump var="#b#" />
Run Code Online (Sandbox Code Playgroud)

这对我们来说显然是一个完整的阻止.我很想知道是否有人遇到过这种情况或者可以在他们的环境中重现这一点.对我们来说,它在100%的时间内运行在Linux上运行的Apache/CF9上,包括RH4和RH5.我们在Java 1.6.0_14上使用默认的JRun安装.

为了查看问题的严重程度,我们运行了一个快速循环来查找受影响的其他命名序列,并找到了2个字母键名的数百个匹配项.类似的循环在3个字母名称中发现了更多冲突.

<cfoutput>Testing a range of affected key combinations. This found hundreds of cases on our platform. Aborting after 50 here.</cfoutput>
<cfscript>
teststring = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
stringlen = len(teststring);
matchesfound = 0;
matches = "";

for (i1 = 1; i1 <= stringlen; i1++) {
    symbol1 = mid(teststring, i1, 1);
    for (i2 = 1; i2 <= stringlen; i2++) {
        teststruct = structnew();
        symbol2 = mid(teststring, i2, 1);
        symbolwhole = symbol1 & symbol2;
        teststruct[ symbolwhole ] = "a string";

        for (q1 = 1; q1 <= stringlen; q1++) {
            innersymbol1 = mid(teststring, q1, 1);
            for (q2 = 1; q2 <= stringlen; q2++) {
                innersymbol2 = mid(teststring, q2, 1);
                innersymbolwhole = innersymbol1 & innersymbol2;
                if ((i1 != q1 || i2 != q2) && structkeyexists(teststruct, innersymbolwhole)) {
                    // another affected pair of keys!
                    writeoutput ("<br />#symbolwhole# = #innersymbolwhole#");
                    if (matchesfound++ > 50) {
                        // we've seen enough
                        abort;
                    }
                }
            }
        }
    }
}
</cfscript>
Run Code Online (Sandbox Code Playgroud)

然后再次编辑:这不仅影响结构键,还影响变量范围中的名称.至少变量作用域存在引发错误,"无法加载null":

<cfset test_b0 = "foo" />
<cfset test_ao = "bar" />
<cfoutput>
test_b0: #test_b0#
<br />test_ao: #test_ao#
</cfoutput>
Run Code Online (Sandbox Code Playgroud)

Hen*_*nry 6

更新:HOTFIX发布: http ://kb2.adobe.com/cps/825/cpsid_82547.html

我想是的,这是一个错误,但这是一个紧急的解决方法:

<cfset a = createObject("java", "java.util.HashMap").init()>
<cfset structInsert(a, "AO", "foo") />

<cfset b = createObject("java", "java.util.HashMap").init()>
<cfset structInsert(b,"AO", "foo") />
<cfset structInsert(b,"B0", "bar") />

<cfoutput>
The following should throw an error. Instead both keys refer to the same value.
<br />Struct a: <cfdump var="#a#" />
<br />a.AO: #a.AO#
<br />a.B0: #a.B0#
<hr />

The following should show a struct with 2 distinct keys and values. Instead it contains a single key, "AO", with a value of "bar".
<br />Struct b: <cfdump var="#b#" />
</cfoutput>
Run Code Online (Sandbox Code Playgroud)

由于struct是HashMap,您仍然可以使用CF中的所有struct函数.

同时,请在以下网址提交错误:http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html