1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

kbx: Allow searching from start.

* kbx/kbxserver.c (cmd_search): Detect empty pattern.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2019-09-09 09:01:28 +02:00
parent 5ea6250cc5
commit 1545b948e1
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 24 additions and 12 deletions

View File

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>. * along with this program; if not, see <https://www.gnu.org/licenses/>.
* SPDX-License-Identifier: GPL-3.0+ * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
#include <config.h> #include <config.h>

View File

@ -225,22 +225,34 @@ cmd_search (assuan_context_t ctx, char *line)
ctrl->server_local->search_any_found = 0; ctrl->server_local->search_any_found = 0;
if (!*line && opt_more) if (!*line)
{
if (opt_more)
{ {
err = set_error (GPG_ERR_INV_ARG, "--more but no pattern"); err = set_error (GPG_ERR_INV_ARG, "--more but no pattern");
goto leave; goto leave;
} }
else if (!*line && ctrl->server_local->search_expecting_more) else if (!*line && ctrl->server_local->search_expecting_more)
{ {
/* It would be too surprising to first set a pattern but finally /* It would be too surprising to first set a pattern but
* add no pattern to search the entire DB. */ * finally add no pattern to search the entire DB. */
err = set_error (GPG_ERR_INV_ARG, "--more pending but no pattern"); err = set_error (GPG_ERR_INV_ARG, "--more pending but no pattern");
goto leave; goto leave;
} }
else /* No pattern - return the first item. */
{
memset (&ctrl->server_local->search_desc, 0,
sizeof ctrl->server_local->search_desc);
ctrl->server_local->search_desc.mode = KEYDB_SEARCH_MODE_FIRST;
}
}
else
{
err = classify_user_id (line, &ctrl->server_local->search_desc, 0); err = classify_user_id (line, &ctrl->server_local->search_desc, 0);
if (err) if (err)
goto leave; goto leave;
}
if (opt_more || ctrl->server_local->search_expecting_more) if (opt_more || ctrl->server_local->search_expecting_more)
{ {
/* More pattern are expected - store the current one and return /* More pattern are expected - store the current one and return