You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by jo...@apache.org on 2019/02/06 05:18:26 UTC

[impala] 07/08: IMPALA-8151: Use sizeof() in HiveUdfCall to specify non-primitive type's size

This is an automated email from the ASF dual-hosted git repository.

joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit ae96a9fb19e0a2e0a5529f2f36d3b5ee0d336f69
Author: poojanilangekar <po...@cloudera.com>
AuthorDate: Mon Feb 4 14:19:44 2019 -0800

    IMPALA-8151: Use sizeof() in HiveUdfCall to specify non-primitive type's size
    
    Previously, data type sizes were hardcoded in
    HiveUdfCall::Evaluate(). Since IMPALA-7367 removed the padding
    from STRING and VARCHAR types, it could read past the end of the
    actual value and cause a crash. This change replaces the hardcoded
    values with  sizeof() calls to determine the size of non-primitive
    types (STRING, VARCHAR and TIMESTAMP) to avoid similar issues in
    the future.
    
    Testing:
    Ran test_udfs.py on an ASAN build.
    Added logs to manually verify the size of bytes copied.
    
    Change-Id: I919c330546fa86b474ab66245b20ceb1f5525b41
    Reviewed-on: http://gerrit.cloudera.org:8080/12355
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 be/src/exprs/hive-udf-call.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/be/src/exprs/hive-udf-call.cc b/be/src/exprs/hive-udf-call.cc
index 22683ca..3d24671 100644
--- a/be/src/exprs/hive-udf-call.cc
+++ b/be/src/exprs/hive-udf-call.cc
@@ -117,9 +117,11 @@ AnyVal* HiveUdfCall::Evaluate(ScalarExprEvaluator* eval, const TupleRow* row) co
           memcpy(input_ptr, v, 8);
           break;
         case TYPE_TIMESTAMP:
+          memcpy(input_ptr, v, sizeof(TimestampValue));
+          break;
         case TYPE_STRING:
         case TYPE_VARCHAR:
-          memcpy(input_ptr, v, 16);
+          memcpy(input_ptr, v, sizeof(StringValue));
           break;
         default:
           DCHECK(false) << "NYI";