瀏覽代碼

HPCC-11402 Extracting a unicode string from a varunicode could truncate it

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 11 年之前
父節點
當前提交
67c39426cd
共有 2 個文件被更改,包括 30 次插入1 次删除
  1. 1 1
      common/deftype/defvalue.cpp
  2. 29 0
      ecl/regress/issue11402.ecl

+ 1 - 1
common/deftype/defvalue.cpp

@@ -927,7 +927,7 @@ const char * VarUnicodeValue::getStringValue(StringBuffer & out)
 
 void * VarUnicodeValue::getUCharStringValue(unsigned len, void * out)
 {
-    unsigned vallen = val.length()/2;
+    unsigned vallen = val.length();
     if(vallen > len)
         vallen = len;
     memcpy(out, val.get(), vallen*2);

+ 29 - 0
ecl/regress/issue11402.ecl

@@ -0,0 +1,29 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2014 HPCC Systems.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+############################################################################## */
+
+import javascript;
+
+unicode add5(unicode val) := EMBED(javascript, (varunicode)U' val+\' at Oh là là Straße\';');
+
+add5(U'Hi');
+
+
+x := dataset('x', { unsigned id; }, csv(terminator((varunicode)'abc')));
+output(x);
+
+OUTPUT(UNICODEORDER(U'abcdef', U'abcxyz'));
+OUTPUT(UNICODEORDER((varunicode)U'abcdef', (varunicode)U'abcxyz'));