Skip to content

cbor BUGFIX stale input log location on load failure - #2596

Open
affan-arch wants to merge 1 commit into
CESNET:masterfrom
affan-arch:cbor-ctx-log-location
Open

affan-arch wants to merge 1 commit into
CESNET:masterfrom
affan-arch:cbor-ctx-log-location

Conversation

@affan-arch

Copy link
Copy Markdown

lycbor_ctx_new() frees the context with a bare free() when cbor_load() fails, so ly_log_location_revert() never runs and the ly_in that lyd_parse_data_mem_len() frees next stays on the log location stack, which means any malformed CBOR input (a lone 0xa1 is enough) leaves the next logged error in that thread reading ->line from freed memory (ASan: heap-use-after-free in ly_vlog_build_path_line()); releasing it through lycbor_ctx_free() like lyjson_ctx_new()/lyxml_ctx_new() do fixes it, and test_invalid_input covers it.

lycbor_ctx_new() freed the context directly when cbor_load() failed,
skipping ly_log_location_revert(), so the freed ly_in stayed on the log
location stack and the next logged error read its line.
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