ZOOM C: don't trust recordPosition always
[yaz-moved-to-github.git] / src / zoom-sru.c
index 9936bdd..687ca83 100644 (file)
@@ -313,7 +313,7 @@ static zoom_ret handle_srw_response(ZOOM_connection c,
         }
         for (i = 0; i<res->num_records; i++)
         {
-            int pos;
+            int pos = *start + i;
             Z_SRW_record *sru_rec;
             Z_SRW_diagnostic *diag = 0;
             int num_diag;
@@ -321,12 +321,10 @@ static zoom_ret handle_srw_response(ZOOM_connection c,
             Z_NamePlusRecord *npr = (Z_NamePlusRecord *)
                 odr_malloc(c->odr_in, sizeof(Z_NamePlusRecord));
 
-            /* recordPosition is 1 based */
+            /* only trust recordPosition if >= calculated position */
             if (res->records[i].recordPosition &&
-                *res->records[i].recordPosition > 0)
+                *res->records[i].recordPosition >= pos + 1)
                 pos = *res->records[i].recordPosition - 1;
-            else
-                pos = *start + i;
 
             sru_rec = &res->records[i];
 
@@ -426,7 +424,7 @@ int ZOOM_handle_sru(ZOOM_connection c, Z_HTTP_Response *hres,
         Z_SOAP *soap_package = 0;
         ODR o = c->odr_in;
         Z_SOAP_Handler soap_handlers[3] = {
-            {YAZ_XMLNS_SRU_v1_1, 0, (Z_SOAP_fun) yaz_srw_codec},
+            {YAZ_XMLNS_SRU_v1_response, 0, (Z_SOAP_fun) yaz_srw_codec},
             {YAZ_XMLNS_SRU_v2_response, 0, (Z_SOAP_fun) yaz_srw_codec},
             {0, 0, 0}
         };