sm: Emit STATUS_FAILURE for non-implemented commands.

* sm/gpgsm.c (main): Do it here.
This commit is contained in:
Werner Koch 2023-05-22 17:00:54 +02:00
parent cd7f286486
commit 5f46bcaaa0
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 13 additions and 5 deletions

View File

@ -1951,11 +1951,17 @@ main ( int argc, char **argv)
break;
case aSignEncr: /* sign and encrypt the given file */
log_error ("this command has not yet been implemented\n");
log_error ("the command '%s' has not yet been implemented\n",
"--sign --encrypt");
gpgsm_status_with_error (&ctrl, STATUS_FAILURE, "option-parser",
gpg_error (GPG_ERR_NOT_IMPLEMENTED));
break;
case aClearsign: /* make a clearsig */
log_error ("this command has not yet been implemented\n");
log_error ("the command '%s' has not yet been implemented\n",
"--clearsign");
gpgsm_status_with_error (&ctrl, STATUS_FAILURE, "option-parser",
gpg_error (GPG_ERR_NOT_IMPLEMENTED));
break;
case aVerify:
@ -2188,8 +2194,10 @@ main ( int argc, char **argv)
default:
log_error (_("invalid command (there is no implicit command)\n"));
break;
log_error (_("invalid command (there is no implicit command)\n"));
gpgsm_status_with_error (&ctrl, STATUS_FAILURE, "option-parser",
gpg_error (GPG_ERR_MISSING_ACTION));
break;
}
/* Print the audit result if needed. */

View File

@ -1530,7 +1530,7 @@ gpgsm_status_with_err_code (ctrl_t ctrl, int no, const char *text,
{
char buf[30];
sprintf (buf, "%u", (unsigned int)ec);
snprintf (buf, sizeof buf, "%u", (unsigned int)ec);
if (text)
return gpgsm_status2 (ctrl, no, text, buf, NULL);
else