Skip to content

Commit

Permalink
Used maximum password request tries.
Browse files Browse the repository at this point in the history
Issue rnpgp#913
  • Loading branch information
joke325 authored and dewyatt committed May 5, 2020
1 parent 56d9ae9 commit ccbfe01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/rnp/fficli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ ffi_pass_callback_stdin(rnp_ffi_t ffi,
char buffer[MAX_PASSWORD_LENGTH];
bool ok = false;
cli_rnp_t *rnp = static_cast<cli_rnp_t *>(app_ctx);
int pswdtries = 1;

if (!ffi || !pgp_context) {
goto done;
Expand Down Expand Up @@ -286,9 +287,13 @@ ffi_pass_callback_stdin(rnp_ffi_t ffi,
goto done;
}
if (strcmp(buf, buffer) != 0) {
fputs("\nPasswords do not match!", rnp->userio_out);
// currently will loop forever
goto start;
fputs("\nPasswords do not match!\n", rnp->userio_out);
fflush(rnp->userio_out);
if (rnp->pswdtries > 0 && ++pswdtries > rnp->pswdtries) {
goto done;
} else {
goto start;
}
}
}
ok = true;
Expand Down
6 changes: 3 additions & 3 deletions src/rnp/rnpcfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,10 @@ rnp_cfg_get_pswdtries(const rnp_cfg_t *cfg)

numtries = rnp_cfg_getstr(cfg, CFG_NUMTRIES);

if ((numtries == NULL) || ((num = atoi(numtries)) <= 0)) {
return MAX_PASSWORD_ATTEMPTS;
} else if (strcmp(numtries, "unlimited")) {
if (numtries != NULL && !strcmp(numtries, "unlimited")) {
return INFINITE_ATTEMPTS;
} else if ((numtries == NULL) || ((num = atoi(numtries)) <= 0)) {
return MAX_PASSWORD_ATTEMPTS;
} else {
return num;
}
Expand Down

0 comments on commit ccbfe01

Please sign in to comment.