Hello, On Windows, passphrase files may have CRLF (\r\n) line endings. This patch removes the trailing '\r' if present, avoiding potential passphrase mismatches during decryption or signing operations. I have requested this patch after personally facing the issue with a passphrase file generated on windows as it was silently including \r in the password and the decryption attempt was failing. Please find the below attached patch details.
Thanks, Vaibhav Sharma --- >From e0e6acca96405c2a291a11074f510e66774925d6 Mon Sep 17 00:00:00 2001 From: VAIBHAV SHARMA <85764094+vaibhav...@users.noreply.github.com> Date: Sun, 15 Jun 2025 17:29:29 +0000 Subject: [PATCH] g10: Handle CRLF endings in passphrase file input * g10/passphrase.c (read_passphrase_from_fd): Trim trailing \r character in passphrase input to correctly handle CRLF endings. Signed-off-by: VAIBHAV SHARMA <85764094+vaibhav...@users.noreply.github.com> --- g10/passphrase.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/g10/passphrase.c b/g10/passphrase.c index c5ec8eae4..32bbc74f6 100644 --- a/g10/passphrase.c +++ b/g10/passphrase.c @@ -150,6 +150,12 @@ read_passphrase_from_fd( int fd ) break; } pw[i] = 0; + + /* Fix for Windows CRLF line endings for passphrase file generated on windows: + If the passphrase ends with a carriage return character ('\r') due to CRLF line endings, strip it. */ + if (i > 0 && pw[i-1] == '\r') + pw[i-1] = 0; + if (!opt.batch && opt.pinentry_mode != PINENTRY_MODE_LOOPBACK) tty_printf("\b\b\b \n" ); -- 2.49.0
_______________________________________________ Gnupg-devel mailing list Gnupg-devel@gnupg.org https://lists.gnupg.org/mailman/listinfo/gnupg-devel