You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "FuzzingTeam (Jira)" <ji...@apache.org> on 2022/10/11 12:08:00 UTC
[jira] [Comment Edited] (HADOOP-18490) The check logic for erasedIndexes in XORRawDecoder is buggy
[ https://issues.apache.org/jira/browse/HADOOP-18490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17615733#comment-17615733 ]
FuzzingTeam edited comment on HADOOP-18490 at 10/11/22 12:07 PM:
-----------------------------------------------------------------
The NullPointerException originates in the method *doDecode* when the code tries to access the erased locations ({*}erasedIndexes[1]{*}, {*}erasedIndexes[2]{*}, etc.) or the locations marked null.
*Code snippet-1 of where the buggy condition is present:*
{code:java}
int erasedIdx = decodingState.erasedIndexes[0];
// Process the inputs.
int iIdx, oIdx;
for (int i = 0; i < decodingState.inputs.length; i++) {
// Skip the erased location.
if (i == erasedIdx) {
continue;
}
for (iIdx = decodingState.inputs[i].position(), oIdx = output.position();
iIdx < decodingState.inputs[i].limit();
iIdx++, oIdx++) {
output.put(oIdx, (byte) (output.get(oIdx) ^
decodingState.inputs[i].get(iIdx)));
}
} {code}
*Code snippet-2 of where the buggy condition is present:*
{code:java}
int erasedIdx = decodingState.erasedIndexes[0];
// Process the inputs.
int iIdx, oIdx;
for (int i = 0; i < decodingState.inputs.length; i++) {
// Skip the erased location.
if (i == erasedIdx) {
continue;
}
for (iIdx = decodingState.inputOffsets[i],
oIdx = decodingState.outputOffsets[0];
iIdx < decodingState.inputOffsets[i] + dataLen; iIdx++, oIdx++) {
output[oIdx] ^= decodingState.inputs[i][iIdx];
}
} {code}
*Solution:-*
We propose to update the current condition of the *erasedIdx* to check for all erased location/s and to add an additional condition for null values in the array ({*}inputs{*}).
We also propose to update the comment above the *erasedIdx* condition, which explains the buggy code.
was (Author: JIRAUSER296392):
The NullPointerException originates in the method *doDecode* when the code tries to access the erased locations ({*}erasedIndexes[1]{*}, {*}erasedIndexes[2]{*}, etc.) or the locations marked null.
*Code snippet-1 of where the buggy condition is present:*
{code:java}
int erasedIdx = decodingState.erasedIndexes[0];
// Process the inputs.
int iIdx, oIdx;
for (int i = 0; i < decodingState.inputs.length; i++) {
// Skip the erased location.
if (i == erasedIdx) {
continue;
}
for (iIdx = decodingState.inputs[i].position(), oIdx = output.position();
iIdx < decodingState.inputs[i].limit();
iIdx++, oIdx++) {
output.put(oIdx, (byte) (output.get(oIdx) ^
decodingState.inputs[i].get(iIdx)));
}
} {code}
{*}Code snippet-2 of where the buggy condition is present:{*}{*}{*}
{code:java}
int erasedIdx = decodingState.erasedIndexes[0];
// Process the inputs.
int iIdx, oIdx;
for (int i = 0; i < decodingState.inputs.length; i++) {
// Skip the erased location.
if (i == erasedIdx) {
continue;
}
for (iIdx = decodingState.inputOffsets[i],
oIdx = decodingState.outputOffsets[0];
iIdx < decodingState.inputOffsets[i] + dataLen; iIdx++, oIdx++) {
output[oIdx] ^= decodingState.inputs[i][iIdx];
}
} {code}
*Solution:-*
We propose to update the current condition of the *erasedIdx* to check for all erased location/s and to add an additional condition for null values in the array ({*}inputs{*}).{*}{*}
We also propose to update the comment above the *erasedIdx* condition, which explains the buggy code.
> The check logic for erasedIndexes in XORRawDecoder is buggy
> -----------------------------------------------------------
>
> Key: HADOOP-18490
> URL: https://issues.apache.org/jira/browse/HADOOP-18490
> Project: Hadoop Common
> Issue Type: Bug
> Affects Versions: 3.3.4
> Reporter: FuzzingTeam
> Priority: Major
> Labels: pull-request-available
>
> In the method _doDecode_ of class {_}XORRawDecoder{_}, the code does not handle all the erased and null marked locations in the array ({_}inputs{_}) but only skips the first erased location ({_}erasedIndexes[0]{_}). The missing handling results in an unhandled NullPointerException.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org