Version v0.2.69 - Fixed stdin pipe mode to use terminal for interactive input
This commit is contained in:
13
otp.c
13
otp.c
@@ -2404,13 +2404,24 @@ int pipe_mode(int argc, char* argv[], const char* piped_text) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Reopen stdin from the controlling terminal for interactive input
|
||||
FILE* tty = fopen("/dev/tty", "r");
|
||||
if (!tty) {
|
||||
printf("Error: Cannot open terminal for input\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("\nEnter pad selection (number, checksum, or prefix): ");
|
||||
fflush(stdout);
|
||||
|
||||
char pad_input[MAX_HASH_LENGTH];
|
||||
if (!fgets(pad_input, sizeof(pad_input), stdin)) {
|
||||
if (!fgets(pad_input, sizeof(pad_input), tty)) {
|
||||
printf("Error: Failed to read pad selection\n");
|
||||
fclose(tty);
|
||||
return 1;
|
||||
}
|
||||
pad_input[strcspn(pad_input, "\n")] = 0;
|
||||
fclose(tty);
|
||||
|
||||
// Encrypt the piped text
|
||||
return encrypt_text(pad_input, piped_text);
|
||||
|
||||
Reference in New Issue
Block a user