mirror of
https://git.sr.ht/~nabijaczleweli/tzpfms
synced 2025-04-15 09:40:32 +03:00
Fix ^Ding out of the new passphrase prompt
This commit is contained in:
parent
b5ff262534
commit
720a0103a7
10
src/fd.cpp
10
src/fd.cpp
@ -5,6 +5,7 @@
|
||||
|
||||
#include "main.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
@ -200,7 +201,7 @@ static int get_key_material_raw(const char * whom, bool again, bool newkey, uint
|
||||
auto bytes = getline((char **)&buf, &buflen, stdin);
|
||||
switch(bytes) {
|
||||
case -1:
|
||||
if(errno != 0)
|
||||
if(errno)
|
||||
TRY("read in passphrase", bytes);
|
||||
else // EOF
|
||||
bytes = 0;
|
||||
@ -269,10 +270,9 @@ int read_new_passphrase(const char * whom, uint8_t *& buf, size_t & len_out, siz
|
||||
if(second_passphrase_len != first_passphrase_len || memcmp(first_passphrase, second_passphrase, first_passphrase_len))
|
||||
return fprintf(stderr, "Provided keys do not match.\n"), __LINE__;
|
||||
|
||||
if(second_passphrase_len) {
|
||||
buf = second_passphrase;
|
||||
second_passphrase = nullptr;
|
||||
} else
|
||||
if(second_passphrase_len)
|
||||
buf = std::exchange(second_passphrase, nullptr);
|
||||
else
|
||||
buf = nullptr;
|
||||
|
||||
len_out = second_passphrase_len;
|
||||
|
@ -16,6 +16,7 @@ int with_stdin_at(int fd, F && what) {
|
||||
|
||||
TRY("dup2() onto stdin", dup2(fd, 0));
|
||||
|
||||
clearerr(stdin);
|
||||
if(int ret = what()) {
|
||||
dup2(stdin_saved, 0);
|
||||
return ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user