apache / apache/beam

Unchecked return value from bis.read() in MutationGroupEncoder#decodeMutation

Open
#18,512 0 comments 0 reactions 0 assignees View on GitHub
bug gcp io java P3
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
2d 5h
Merged PRs (30d)
204

Description

```

private Mutation decodeMutation(ByteArrayInputStream bis) throws IOException {
Mutation.Op op
= Mutation.Op.values()[bis.read()];
if (op == Mutation.Op.DELETE) {
return decodeDelete(bis);

```

The return value from bis.read() should be checked before it is used to dereference values().

Imported from Jira [BEAM-3140](https://issues.apache.org/jira/browse/BEAM-3140). Original Jira may contain additional context.
Reported by: yuzhihong@gmail.com.

Contributor guide

Open the contributing guide

Research direction

Start at MutationGroupEncoder#decodeMutation and inspect how bis.read() is used before Mutation.Op.values(). Confirm the return value is handled safely before lookup, then verify the relevant Beam tests pass and that truncated input no longer causes an unchecked lookup.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.