hx509: Show query expression parse errors

This commit is contained in:
Nicolas Williams
2019-11-07 21:47:54 -06:00
parent a40d4056bd
commit 4500a14f95
3 changed files with 22 additions and 6 deletions

View File

@@ -2979,12 +2979,21 @@ hx509_query_match_expr(hx509_context context, hx509_query *q, const char *expr)
if (expr == NULL) {
q->match &= ~HX509_QUERY_MATCH_EXPR;
} else {
q->expr = _hx509_expr_parse(expr);
if (q->expr)
q->match |= HX509_QUERY_MATCH_EXPR;
return 0;
}
q->expr = _hx509_expr_parse(expr);
if (q->expr == NULL) {
const char *reason = _hx509_expr_parse_error();
hx509_set_error_string(context, 0, EINVAL,
"Invalid certificate query match expression: "
"%s (%s)", expr,
reason ? reason : "syntax error");
return EINVAL;
}
q->match |= HX509_QUERY_MATCH_EXPR;
return 0;
}