Version v0.2.69 - Fixed stdin pipe mode to use terminal for interactive input

This commit is contained in:
2025-08-14 10:29:32 -04:00
parent 692f65b7f0
commit 8c8c873e73

13
otp.c
View File

@@ -2404,13 +2404,24 @@ int pipe_mode(int argc, char* argv[], const char* piped_text) {
return 1; 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): "); printf("\nEnter pad selection (number, checksum, or prefix): ");
fflush(stdout);
char pad_input[MAX_HASH_LENGTH]; 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"); printf("Error: Failed to read pad selection\n");
fclose(tty);
return 1; return 1;
} }
pad_input[strcspn(pad_input, "\n")] = 0; pad_input[strcspn(pad_input, "\n")] = 0;
fclose(tty);
// Encrypt the piped text // Encrypt the piped text
return encrypt_text(pad_input, piped_text); return encrypt_text(pad_input, piped_text);