Skip to content

parser BUGFIX do not expect a stored error item - #2664

Open
Mohil-Ahuja wants to merge 1 commit into
CESNET:develfrom
Mohil-Ahuja:err-item-null
Open

Mohil-Ahuja wants to merge 1 commit into
CESNET:develfrom
Mohil-Ahuja:err-item-null

Conversation

@Mohil-Ahuja

Copy link
Copy Markdown

With LYD_VALIDATE_MULTI_ERROR, lyd_parse() and LY_DPARSER_ERR_GOTO read ly_err_last() to decide whether to keep parsing after an error. If the application does not store errors (ly_log_options() without LY_LOSTORE), there is no error item, and any invalid value crashes the parser:

ly_log_options(LY_LOLOG);
lyd_parse_data_mem(ctx, "<foo3 xmlns=\"urn:tests:a\">x</foo3>", LYD_XML, 0,
        LYD_VALIDATE_PRESENT | LYD_VALIDATE_MULTI_ERROR, &tree);   /* SIGSEGV */

Without a stored error item, parsing now stops as it does for a syntax error. The schema-mount parent-reference callback in xpath1.0.c had the same unchecked ly_err_last(), so it now falls back to a generic message. A test case is added to test_leaf.

With LYD_VALIDATE_MULTI_ERROR, lyd_parse() and LY_DPARSER_ERR_GOTO read
the last error item to decide whether to continue, but there is none
when the application does not store errors (ly_log_options() without
LY_LOSTORE), so an invalid value crashed the parser. Stop parsing in
that case. The schema-mount parent-reference xpath1.0 value callback
had the same NULL dereference.
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