Impala Public Jenkins has submitted this change and it was merged. ( 
http://gerrit.cloudera.org:8080/21501 )

Change subject: IMPALA-13150: Possible buffer overflow in StringVal::CopyFrom()
......................................................................

IMPALA-13150: Possible buffer overflow in StringVal::CopyFrom()

In StringVal::CopyFrom(), we take the 'len' parameter as a size_t, which
is usually a 64-bit unsigned integer. We pass it to the constructor of
StringVal, which takes it as an int, which is usually a 32-bit signed
integer. The constructor then allocates memory for the length using the
int value, but afterwards in CopyFrom(), we copy the buffer with the
size_t length. If size_t is indeed 64 bits and int is 32 bits, and the
value is truncated, we may copy more bytes that what we have allocated
for the destination.

Note that in the constructor of StringVal it is checked whether the
length is greater than 1GB, but if the value is truncated because of the
type conversion, the check doesn't necessarily catch it as the truncated
value may be small.

This change fixes the problem by doing the length check with 64 bit
integers in StringVal::CopyFrom().

Testing:
 - added unit tests for StringVal::CopyFrom() in udf-test.cc.

Change-Id: I6a1d03d65ec4339a0f33e69ff29abdd8cc3e3067
Reviewed-on: http://gerrit.cloudera.org:8080/21501
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>
---
M be/src/udf/udf-test.cc
M be/src/udf/udf.cc
M be/src/udf/udf.h
3 files changed, 89 insertions(+), 17 deletions(-)

Approvals:
  Impala Public Jenkins: Looks good to me, approved; Verified

--
To view, visit http://gerrit.cloudera.org:8080/21501
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6a1d03d65ec4339a0f33e69ff29abdd8cc3e3067
Gerrit-Change-Number: 21501
Gerrit-PatchSet: 5
Gerrit-Owner: Daniel Becker <[email protected]>
Gerrit-Reviewer: Csaba Ringhofer <[email protected]>
Gerrit-Reviewer: Daniel Becker <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Noemi Pap-Takacs <[email protected]>
Gerrit-Reviewer: Peter Rozsa <[email protected]>

Reply via email to