Skip to content

PVA: harden handling of protocol sizes#3878

Open
kasemir wants to merge 2 commits into
masterfrom
pva_harden
Open

PVA: harden handling of protocol sizes#3878
kasemir wants to merge 2 commits into
masterfrom
pva_harden

Conversation

@kasemir

@kasemir kasemir commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Protocol handling was prone to memory exhaustion because of this pattern:

int count = buffer.getInteger();
Whatever[] data = new Whatever[count];
.. then read data from buffer,
.. which may actually be too small for 'count' elements

A misconfigured package can contain a huge count. This update checks the count against the remaining package size, refusing packets that are obviously too small or rather the count is obviously too large for the packet size.

Along the same lines, one could introduce an upper packet size limit similar to EPICS_CA_MAX_ARRAY_BYTES in channel access, but at this time, confirmed in a 2026-07-10 EPICS core telecon, PVA does not impose any such size limits, using all available memory.

kasemir added 2 commits July 10, 2026 13:48
Protocol handling was prone to memory exhaustion because of this pattern:
```
int count = buffer.getInteger();
Whatever[] data = new Whatever[count];
.. then read data from buffer
```

A misconfigured package can contain a huge `count`.
This update checks the `count` against the remaining package size, refusing packets that are obviously too small or rather the `count` is obviously too large for the packet size.

Along the same lines, one could introduce an upper packet size limit similar to `EPICS_CA_MAX_ARRAY_BYTES` in channel access, but at this time, confirmed in a 2026-07-10 EPICS core telecon, PVA does not impose any such size limits, using all available memory.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
D Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

💡 Need a hand with PR review? Try Gitar by Sonar!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant