You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Vincent Tran (JIRA)" <ji...@apache.org> on 2018/08/21 18:08:00 UTC

[jira] [Commented] (IMPALA-6844) Fix possible NULL dereference in to_date() builtin

    [ https://issues.apache.org/jira/browse/IMPALA-6844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16587816#comment-16587816 ] 

Vincent Tran commented on IMPALA-6844:
--------------------------------------

Reproduction with the fault injector --stress_fn_ctx_alloc=1

{noformat}
[localhost:21000] default> select max(string_col) from functional.alltypes;
Query: select max(string_col) from functional.alltypes
Query submitted at: 2018-08-21 14:00:09 (Coordinator: http://blackbox.vpc.cloudera.com:25000)
Query progress can be monitored at: http://blackbox.vpc.cloudera.com:25000/query_plan?query_id=7a4b1f1bd78bf8dc:ff36064a00000000
WARNINGS: UDF ERROR: FunctionContext::Allocate() failed to allocate 1 bytes.

[localhost:21000] default> select to_date(now());
Query: select to_date(now())
Query submitted at: 2018-08-21 14:01:04 (Coordinator: http://blackbox.vpc.cloudera.com:25000)
Error communicating with impalad: TSocket read 0 bytes
[Not connected] >
{noformat}


> Fix possible NULL dereference in to_date() builtin
> --------------------------------------------------
>
>                 Key: IMPALA-6844
>                 URL: https://issues.apache.org/jira/browse/IMPALA-6844
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Backend
>    Affects Versions: Impala 2.9.0, Impala 2.10.0, Impala 2.11.0
>            Reporter: bharath v
>            Assignee: Vincent Tran
>            Priority: Critical
>              Labels: crash, newbie
>
> If {{result.ptr}} allocation fails for some reason inside the {{StringVal}} constructor, we still overwrite {{result.len}} and continue.
> {noformat}
> StringVal TimestampFunctions::ToDate(FunctionContext* context,
> const TimestampVal& ts_val) {
> if (ts_val.is_null) return StringVal::null();
> const TimestampValue ts_value = TimestampValue::FromTimestampVal(ts_val);
> // Defensively, return NULL if the timestamp does not have a date portion. Some of
> // our built-in functions might incorrectly return such a malformed timestamp.
> if (!ts_value.HasDate()) return StringVal::null();
> StringVal result(context, 10);
> result.len = 10;
> // Fill in year, month, and day.
> IntToChar(result.ptr, ts_value.date().year(), 4);  <-----
> IntToChar(result.ptr + 5, ts_value.date().month(), 2);
> IntToChar(result.ptr + 8, ts_value.date().day(), 2);
> // Fill in dashes.
> result.ptr[7] = '-';
> result.ptr[4] = '-';
> return result;
> }
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org