From 86878f261a0679ae4cbddad2f8eb3208722e2e3b Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 24 Mar 2011 10:33:34 +0100 Subject: [PATCH] ZOOM: diagnostics for invalid ES usage, bug #3893. --- include/yaz/zoom.h | 3 +++ src/zoom-c.c | 6 ++++++ src/zoom-z3950.c | 9 ++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/yaz/zoom.h b/include/yaz/zoom.h index 4b0a4cc..a505e12 100644 --- a/include/yaz/zoom.h +++ b/include/yaz/zoom.h @@ -140,6 +140,9 @@ ZOOM_diag_str (int error); #define ZOOM_ERROR_CQL_TRANSFORM 10012 #define ZOOM_ERROR_CCL_CONFIG 10013 #define ZOOM_ERROR_CCL_PARSE 10014 +#define ZOOM_ERROR_ES_INVALID_ACTION 10015 +#define ZOOM_ERROR_ES_INVALID_VERSION 10016 +#define ZOOM_ERROR_ES_INVALID_SYNTAX 10017 ZOOM_API(int) ZOOM_connection_last_event(ZOOM_connection cs); diff --git a/src/zoom-c.c b/src/zoom-c.c index 005e724..c3aa0ed 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -1881,6 +1881,12 @@ ZOOM_API(const char *) return "CCL configuration error"; case ZOOM_ERROR_CCL_PARSE: return "CCL parsing error"; + case ZOOM_ERROR_ES_INVALID_ACTION: + return "Extended Service. invalid action"; + case ZOOM_ERROR_ES_INVALID_VERSION: + return "Extended Service. invalid version"; + case ZOOM_ERROR_ES_INVALID_SYNTAX: + return "Extended Service. invalid syntax"; default: return diagbib1_str(error); } diff --git a/src/zoom-z3950.c b/src/zoom-z3950.c index 2598eae..a8cf99b 100644 --- a/src/zoom-z3950.c +++ b/src/zoom-z3950.c @@ -324,12 +324,15 @@ static Z_APDU *create_update_package(ZOOM_package p) p->odr_out); } if (!syntax_oid) + { + ZOOM_set_error(p->connection, ZOOM_ERROR_ES_INVALID_SYNTAX, syntax_str); return 0; + } if (num_db > 0) first_db = db[0]; - switch(*version) + switch (*version) { case '1': package_oid = yaz_oid_extserv_database_update_first_version; @@ -348,6 +351,7 @@ static Z_APDU *create_update_package(ZOOM_package p) package_oid = yaz_oid_extserv_database_update; break; default: + ZOOM_set_error(p->connection, ZOOM_ERROR_ES_INVALID_VERSION, version); return 0; } @@ -362,7 +366,10 @@ static Z_APDU *create_update_package(ZOOM_package p) else if (!strcmp(action, "specialUpdate")) action_no = Z_IUOriginPartToKeep_specialUpdate; else + { + ZOOM_set_error(p->connection, ZOOM_ERROR_ES_INVALID_ACTION, action); return 0; + } apdu = create_es_package(p, package_oid); if (apdu) -- 1.7.10.4