From 8c8c873e73f58e0effe7dd4e1324d6e956488326 Mon Sep 17 00:00:00 2001 From: Laan Tungir Date: Thu, 14 Aug 2025 10:29:32 -0400 Subject: [PATCH] Version v0.2.69 - Fixed stdin pipe mode to use terminal for interactive input --- otp.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/otp.c b/otp.c index 215de95..9ce67a8 100644 --- a/otp.c +++ b/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);