[
https://issues.apache.org/jira/browse/IMPALA-12986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17836540#comment-17836540
]
ASF subversion and git services commented on IMPALA-12986:
----------------------------------------------------------
Commit ef6dad694d131f600478798674ed460d2391e7ac in impala's branch
refs/heads/master from Daniel Becker
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=ef6dad694 ]
IMPALA-12986: Base64Encode fails if the 'out_len' output parameter is passed
with certain values
The Base64Encode function in coding-util.h with signature
bool Base64Encode(const char* in, int64_t in_len, int64_t out_max,
char* out, int64_t* out_len);
fails if '*out_len', when passed to the function, contains a value that
does not fit in a 32 bit integer.
Internally we use the
int sasl_encode64(const char *in, unsigned inlen, char *out, unsigned
outmax, unsigned *outlen);
function and explicitly cast 'out_len' to 'unsigned*'.
The error is that the called sasl_encode64() function only sets the four
lower bytes of '*out_len' (assuming that 'unsigned' is a 32 bit
integer), and if the upper bytes are not all zero, the resulting value
of '*out_len' will be incorrect.
This change changes the type of 'out_len' from 'int64_t*' to 'unsigned*'
to match the type that sasl_encode64() expects.
Base64Decode() is also updated to use 'unsigned*'. Before this change it
used an intermediate 32 bit local variable to avoid this issue.
Testing:
- added a regression test in coding-util-test.cc
Change-Id: I35ae59fc9b3280f89ea4f7d95d27d2f21751001f
Reviewed-on: http://gerrit.cloudera.org:8080/21271
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>
> Base64Encode fails if the 'out_len' output parameter is passed with certain
> values
> ----------------------------------------------------------------------------------
>
> Key: IMPALA-12986
> URL: https://issues.apache.org/jira/browse/IMPALA-12986
> Project: IMPALA
> Issue Type: Bug
> Components: Backend
> Reporter: Daniel Becker
> Assignee: Daniel Becker
> Priority: Major
>
> The Base64Encode function in coding-util.h with signature
> {code:java}
> bool Base64Encode(const char* in, int64_t in_len, int64_t out_max, char* out,
> int64_t* out_len);{code}
> fails if '*out_len', when passed to the function, contains a negative value
> or a value that does not fit in a 32 bit integer.
> Internally we use the
>
> {code:java}
> int sasl_encode64(const char *in, unsigned inlen, char *out, unsigned outmax,
> unsigned *outlen);{code}
>
> function and explicitly cast 'out_len' to 'unsigned*'.
> The success of this function shouldn't depend on the value of '*out_len'
> because it is an output parameter, so we should set '*out_len' to zero before
> passing it to {{{}sasl_encode64(){}}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]