kbx: Fix keyboxd search first.
authorWerner Koch <wk@gnupg.org>
Mon, 9 Sep 2019 12:25:02 +0000 (14:25 +0200)
committerWerner Koch <wk@gnupg.org>
Mon, 9 Sep 2019 12:25:02 +0000 (14:25 +0200)
* kbx/kbxserver.c (cmd_next): Switch to mode next if needed.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
kbx/kbxserver.c

index a544441..df110b3 100644 (file)
@@ -352,10 +352,24 @@ cmd_next (assuan_context_t ctx, char *line)
 
   ctrl->no_data_return = opt_no_data;
   if (ctrl->server_local->multi_search_desc_len)
-    err = kbxd_search (ctrl, ctrl->server_local->multi_search_desc,
-                       ctrl->server_local->multi_search_desc_len, 0);
+    {
+      /* The next condition should never be tru but we better handle
+       * the first/next transition anyway.  */
+      if (ctrl->server_local->multi_search_desc[0].mode
+          == KEYDB_SEARCH_MODE_FIRST)
+        ctrl->server_local->multi_search_desc[0].mode = KEYDB_SEARCH_MODE_NEXT;
+
+      err = kbxd_search (ctrl, ctrl->server_local->multi_search_desc,
+                         ctrl->server_local->multi_search_desc_len, 0);
+    }
   else
-    err = kbxd_search (ctrl, &ctrl->server_local->search_desc, 1, 0);
+    {
+      /* We need to do the transition from first to next here.  */
+      if (ctrl->server_local->search_desc.mode == KEYDB_SEARCH_MODE_FIRST)
+        ctrl->server_local->search_desc.mode = KEYDB_SEARCH_MODE_NEXT;
+
+      err = kbxd_search (ctrl, &ctrl->server_local->search_desc, 1, 0);
+    }
   if (err)
     goto leave;