Detect and throw Present Out of Range diagnostic
[metaproxy-moved-to-github.git] / src / filter_multi.cpp
index f728724..8ddc5a8 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of Metaproxy.
-   Copyright (C) 2005-2009 Index Data
+   Copyright (C) 2005-2010 Index Data
 
 Metaproxy is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
@@ -20,15 +20,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "config.hpp"
 
-#include "filter.hpp"
-#include "package.hpp"
+#include <metaproxy/filter.hpp>
+#include <metaproxy/package.hpp>
 
 #include <boost/thread/thread.hpp>
 #include <boost/thread/mutex.hpp>
 #include <boost/thread/condition.hpp>
 #include <boost/shared_ptr.hpp>
 
-#include "util.hpp"
+#include <metaproxy/util.hpp>
 #include "filter_multi.hpp"
 
 #include <yaz/zgdu.h>
@@ -766,6 +766,14 @@ void yf::Multi::Frontend::present(mp::Package &package, Z_APDU *apdu_req)
         f_resp->records = z_records_diag;
         *f_resp->presentStatus = Z_PresentStatus_failure;
     }
+    else if (number < 0 || number > jobs.size())
+    {
+        f_apdu = 
+            odr.create_presentResponse(
+                apdu_req,
+                YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE,
+                0);
+    }
     else
     {
         f_resp->records = (Z_Records *) odr_malloc(odr, sizeof(Z_Records));