File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,7 @@ ffi_pass_callback_stdin(rnp_ffi_t ffi,
252252 char buffer[MAX_PASSWORD_LENGTH];
253253 bool ok = false ;
254254 cli_rnp_t *rnp = static_cast <cli_rnp_t *>(app_ctx);
255+ int pswdtries = 1 ;
255256
256257 if (!ffi || !pgp_context) {
257258 goto done;
@@ -286,9 +287,13 @@ ffi_pass_callback_stdin(rnp_ffi_t ffi,
286287 goto done;
287288 }
288289 if (strcmp (buf, buffer) != 0 ) {
289- fputs (" \n Passwords do not match!" , rnp->userio_out );
290- // currently will loop forever
291- goto start;
290+ fputs (" \n Passwords do not match!\n " , rnp->userio_out );
291+ fflush (rnp->userio_out );
292+ if (rnp->pswdtries > 0 && ++pswdtries > rnp->pswdtries ) {
293+ goto done;
294+ } else {
295+ goto start;
296+ }
292297 }
293298 }
294299 ok = true ;
Original file line number Diff line number Diff line change @@ -486,10 +486,10 @@ rnp_cfg_get_pswdtries(const rnp_cfg_t *cfg)
486486
487487 numtries = rnp_cfg_getstr (cfg, CFG_NUMTRIES);
488488
489- if ((numtries == NULL ) || ((num = atoi (numtries)) <= 0 )) {
490- return MAX_PASSWORD_ATTEMPTS;
491- } else if (strcmp (numtries, " unlimited" )) {
489+ if (numtries != NULL && !strcmp (numtries, " unlimited" )) {
492490 return INFINITE_ATTEMPTS;
491+ } else if ((numtries == NULL ) || ((num = atoi (numtries)) <= 0 )) {
492+ return MAX_PASSWORD_ATTEMPTS;
493493 } else {
494494 return num;
495495 }
You can’t perform that action at this time.
0 commit comments