From 7a464badf789151889130191602d5dea5ba1d243 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 7 Nov 2011 12:23:32 +0100 Subject: [PATCH] Check for valid limitmap --- src/client.c | 19 +++++++++++++++---- src/session.c | 16 ++++++++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/client.c b/src/client.c index c9ac78f..0ae3641 100644 --- a/src/client.c +++ b/src/client.c @@ -988,10 +988,11 @@ static char *make_solrquery(struct client *cl) return r; } -static void apply_limit(struct session_database *sdb, - facet_limits_t facet_limits, - WRBUF w_pqf, WRBUF w_ccl) +static int apply_limit(struct session_database *sdb, + facet_limits_t facet_limits, + WRBUF w_pqf, WRBUF w_ccl) { + int ret = 0; int i = 0; const char *name; const char *value; @@ -1043,6 +1044,14 @@ static void apply_limit(struct session_database *sdb, wrbuf_puts(w_ccl, ")"); } + else if (!strncmp(s->value, "local:", 6)) + ; + else + { + yaz_log(YLOG_WARN, "Target %s: Bad limitmap '%s'", + sdb->database->id, s->value); + ret = -1; /* bad limitmap */ + } break; } } @@ -1054,6 +1063,7 @@ static void apply_limit(struct session_database *sdb, } } nmem_destroy(nmem_tmp); + return ret; } // Parse the query given the settings specific to this client @@ -1099,7 +1109,8 @@ int client_parse_query(struct client *cl, const char *query, wrbuf_puts(w_pqf, " "); } - apply_limit(sdb, facet_limits, w_pqf, w_ccl); + if (apply_limit(sdb, facet_limits, w_pqf, w_ccl)) + return -2; yaz_log(YLOG_LOG, "CCL query: %s", wrbuf_cstr(w_ccl)); cn = ccl_find_str(ccl_map, wrbuf_cstr(w_ccl), &cerror, &cpos); diff --git a/src/session.c b/src/session.c index a48f69b..ac41b36 100644 --- a/src/session.c +++ b/src/session.c @@ -689,7 +689,8 @@ enum pazpar2_error_code session_search(struct session *se, { int live_channels = 0; int no_working = 0; - int no_failed = 0; + int no_failed_query = 0; + int no_failed_limit = 0; struct client_list *l, *l0; struct timeval tval; facet_limits_t facet_limits; @@ -753,8 +754,10 @@ enum pazpar2_error_code session_search(struct session *se, parse_ret = client_parse_query(cl, query, facet_limits, startrecs, maxrecs); - if (parse_ret < 0) - no_failed++; + if (parse_ret == -1) + no_failed_query++; + else if (parse_ret == -2) + no_failed_limit++; else if (parse_ret == 0) { session_log(se, YLOG_LOG, "client NEW %s", client_get_id(cl)); @@ -783,11 +786,16 @@ enum pazpar2_error_code session_search(struct session *se, if (no_working == 0) { - if (no_failed > 0) + if (no_failed_query > 0) { *addinfo = "query"; return PAZPAR2_MALFORMED_PARAMETER_VALUE; } + else if (no_failed_limit > 0) + { + *addinfo = "limit"; + return PAZPAR2_MALFORMED_PARAMETER_VALUE; + } else return PAZPAR2_NO_TARGETS; } -- 1.7.10.4