Skip to content

ioc: size a DBR_STRING array read by the request stride, not field_size - #206

Closed
physwkim wants to merge 1 commit into
epics-base:masterfrom
physwkim:fix/qsrv2-dbf-string-array-overflow
Closed

ioc: size a DBR_STRING array read by the request stride, not field_size#206
physwkim wants to merge 1 commit into
epics-base:masterfrom
physwkim:fix/qsrv2-dbf-string-array-overflow

Conversation

@physwkim

@physwkim physwkim commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

getArrayValue sized its buffer from dbChannelFinalFieldSize, but dbGet writes dbValueSize(final_type) bytes per element — MAX_STRING_SIZE for a DBR_STRING request regardless of the field's own size — so a DBF_STRING field with field_size < 40 (synApps scalcout's PAA..PLL) overflowed the heap.

Size by dbValueSize(final_type) instead: unchanged for numeric fields and type-changing filters (where dbValueSize == field_size, e.g. ts -> DBR_DOUBLE), and MAX_STRING_SIZE for strings. This keeps the field_size-based design while making a malformed field_size unable to overrun the buffer.

Fixes #205.

getArrayValue sized the read buffer from dbChannelFinalFieldSize, but dbGet
writes dbValueSize(final_type) bytes per element — MAX_STRING_SIZE for a
DBR_STRING request, regardless of the field's own size — so a DBF_STRING field
with field_size < MAX_STRING_SIZE (synApps scalcout PAA..PLL) overflowed the
heap. Size by dbValueSize(final_type): unchanged for numeric fields and
type-changing filters (dbValueSize == field_size there), MAX_STRING_SIZE for
strings.
@physwkim
physwkim force-pushed the fix/qsrv2-dbf-string-array-overflow branch from 21cb41e to d35f3bf Compare August 31, 2026 15:02
@physwkim physwkim changed the title ioc: size a DBR_STRING array read by MAX_STRING_SIZE, not field_size ioc: size a DBR_STRING array read by the request stride, not field_size Aug 31, 2026
@mdavidsaver

Copy link
Copy Markdown
Member

Applied with modifications as ce35c27. Thanks.

@mdavidsaver mdavidsaver closed this Sep 5, 2026
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.

QSRV2 heap overflow reading a DBF_STRING array whose field_size < MAX_STRING_SIZE

2 participants