X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-proxy.cpp;h=476e045aa7955e27456869e8c8f3aac86f6abeaa;hb=068845aaefa709c1729137b36b46688e1acc498e;hp=ea0e19784569f8c07076f13b081fb08f2e59a0f3;hpb=b0a1f7ae808c0fc63a3b347421fbff3cdbe8791b;p=yazproxy-moved-to-github.git diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index ea0e197..476e045 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy.cpp,v 1.59 2006-04-16 07:35:06 adam Exp $ +/* $Id: yaz-proxy.cpp,v 1.61 2006-04-22 07:03:34 adam Exp $ Copyright (c) 1998-2006, Index Data. This file is part of the yazproxy. @@ -1611,8 +1611,21 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu) { Z_APDU *new_apdu = create_Z_PDU(Z_APDU_presentResponse); new_apdu->u.presentResponse->records = - create_nonSurrogateDiagnostics(odr_encode(), 30, - pr->resultSetId); + create_nonSurrogateDiagnostics( + odr_encode(), + YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST, + pr->resultSetId); + send_to_client(new_apdu); + return 0; + } + if (start < 1 || toget < 0) + { + Z_APDU *new_apdu = create_Z_PDU(Z_APDU_presentResponse); + new_apdu->u.presentResponse->records = + create_nonSurrogateDiagnostics( + odr_encode(), + YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE, + 0); send_to_client(new_apdu); return 0; } @@ -1622,7 +1635,10 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu) { Z_APDU *new_apdu = create_Z_PDU(Z_APDU_presentResponse); new_apdu->u.presentResponse->records = - create_nonSurrogateDiagnostics(odr_encode(), 13, 0); + create_nonSurrogateDiagnostics( + odr_encode(), + YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE, + 0); send_to_client(new_apdu); return 0; } @@ -1668,6 +1684,21 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu) this_query->set_Z_Query(sr->query); + // Check for non-negative piggyback params. + if (*sr->smallSetUpperBound < 0 + || *sr->largeSetLowerBound < 0 + || *sr->mediumSetPresentNumber < 0) + { + Z_APDU *new_apdu = create_Z_PDU(Z_APDU_searchResponse); + // Not a present request.. But can't find better diagnostic + new_apdu->u.searchResponse->records = + create_nonSurrogateDiagnostics( + odr_encode(), + YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE, 0); + send_to_client(new_apdu); + return 0; + } + char query_str[120]; this_query->print(query_str, sizeof(query_str)-1); yaz_log(YLOG_LOG, "%sSearch %s", m_session_str, query_str); @@ -1688,7 +1719,7 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu) if (toget > m_client->m_last_resultCount) toget = m_client->m_last_resultCount; - + if (sr->mediumSetElementSetNames) { comp = (Z_RecordComposition *) @@ -1848,6 +1879,25 @@ void Yaz_Proxy::recv_GDU(Z_GDU *apdu, int len) yaz_log (YLOG_LOG, "%sReceiving %s from client %d bytes", m_session_str, gdu_name(apdu), len); +#if 0 + // try to make a _bad_ attribute set ID .. Don't enable this in prod. + if (apdu->which == Z_GDU_Z3950 + && apdu->u.z3950->which == Z_APDU_searchRequest) + { + Z_SearchRequest *req = apdu->u.z3950->u.searchRequest; + if (req->query && req->query->which == Z_Query_type_1) + { + Z_RPNQuery *rpnquery = req->query->u.type_1; + if (rpnquery->attributeSetId) + { + rpnquery->attributeSetId[0] = -2; + rpnquery->attributeSetId[1] = -1; + yaz_log(YLOG_WARN, "%sBAD FIXUP TEST", m_session_str); + } + } + } +#endif + #if HAVE_GETTIMEOFDAY gettimeofday((struct timeval *) m_time_tv, 0); #endif @@ -1855,8 +1905,16 @@ void Yaz_Proxy::recv_GDU(Z_GDU *apdu, int len) m_pdu_stat.add_bytes(1); GDU *gdu = new GDU(apdu); - m_in_queue.enqueue(gdu); + if (gdu->get() == 0) + { + delete gdu; + yaz_log(YLOG_LOG, "%sUnable to encode package", m_session_str); + m_in_queue.clear(); + dec_ref(true); + return; + } + m_in_queue.enqueue(gdu); recv_GDU_more(false); } @@ -3090,23 +3148,6 @@ void Yaz_Proxy::handle_init(Z_APDU *apdu) void Yaz_Proxy::handle_incoming_Z_PDU(Z_APDU *apdu) { -#if 0 - // try to make a _bad_ attribute set ID .. Don't enable this in prod. - if (apdu->which == Z_APDU_searchRequest) - { - Z_SearchRequest *req = apdu->u.searchRequest; - if (req->query && req->query->which == Z_Query_type_1) - { - Z_RPNQuery *rpnquery = req->query->u.type_1; - if (rpnquery->attributeSetId) - { - rpnquery->attributeSetId[0] = -2; - rpnquery->attributeSetId[1] = -1; - yaz_log(YLOG_WARN, "%sBAD FIXUP TEST", m_session_str); - } - } - } -#endif Z_ReferenceId **refid = get_referenceIdP(apdu); nmem_reset(m_referenceId_mem); if (refid && *refid)