[PATCH] gpg: Show error when deleting keys without a key identifier

Ashish Gupta ashmew2 at gmail.com
Sun May 29 13:57:31 CEST 2016


[PATCH] gpg: Show error when deleting keys without a key identifier

* Add an error message to the output when the user does not supply a key
to be deleted with --delete-keys or --delete-secret-keys.
--
* Return a GPG_ERR_NOT_FOUND for the NULL key in this case.

Signed-off-by: Ashish Gupta <ashmew2 at gmail d0t c0m>
---
 g10/delkey.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/g10/delkey.c b/g10/delkey.c
index 966c571..a679494 100644
--- a/g10/delkey.c
+++ b/g10/delkey.c
@@ -259,6 +259,13 @@ delete_keys (strlist_t names, int secret, int allow_both)
   /* Force allows us to delete a public key even if a secret key
      exists. */

+  /* If no key was specified for deleting, show error message */
+  if ( !names )
+    {
+      log_error (_("No key was specified for deletion.\n"));
+      return GPG_ERR_NOT_FOUND;
+    }
+
   for ( ;names ; names=names->next )
     {
       err = do_delete_key (names->d, secret, force, &avail);
-- 
2.7.3
-------------- next part --------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAABCAAGBQJXStiKAAoJEFzyLcYjLACbFBUIAMZPAT53U0UPDdhfRfetAPB9
el4V/2fp8XJmpUvGzT9/S0KHQgPw1Q1RzRtT3Hg4L2blr8VB4oar3YsC9uM0gg92
98TKp7BgH6cT5z0tW786KiajSI/oz7AudBic5l55VM6FSSsWhGiWuI8dmW+Rqvy0
614m5yfLN5x5ZiiPDg1sVuIbPHmyORvEcqTIxjhxgf8wJ7UxxGib3aPCsFmVcPWU
s40j3NHlyZlSt9GQ4e9L/2NuPFB2v3obdvhDmC/aK4dJAyrtZyxoxJduiVIrxBeg
HgmmZbFHgvzYLyAYc2cx2/mBwFQDnVwfQklsylqnHlFNOLcTMlQcQcl/1x0PsbI=
=Xreh
-----END PGP SIGNATURE-----


More information about the Gnupg-devel mailing list