perf_hooks: validate import normalization offset · nodejs/node@9cfbfae · GitHub
Skip to content

Commit 9cfbfae

Browse files
mcollinaaduh95
authored andcommitted
perf_hooks: validate import normalization offset
The CBOR importer accepts a normalizing_index_offset outside the range of the allocated counts array. normalize_index() in hdr_histogram.c applies at most one wrap adjustment of +/-counts_len, so an arbitrary offset can remain out of bounds and a later record() performs an out-of-bounds native write in counts_inc_normalised(). Reject offsets that are not representable as int32_t when reading the CBOR field, and reject offsets outside [0, counts_len) after the histogram is reconstructed. Add regression tests covering the boundary at counts_len, offsets beyond it, and values that cannot be represented as int32_t. Signed-off-by: Matteo Collina <hello@matteocollina.com> Assisted-by: pi PR-URL: #65950 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 01032f4 commit 9cfbfae

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

‎src/histogram.cc‎

Lines changed: 11 additions & 0 deletions

‎test/parallel/test-perf-hooks-histogram-stats.js‎

Lines changed: 54 additions & 0 deletions

0 commit comments

Comments
 (0)