|
From: Avinash H. D. <no...@gi...> - 2026-09-03 12:27:29
|
Branch: refs/heads/master Home: https://github.com/OpenSC/OpenSC Commit: 13fa934260854840442f02c0fdfed2affd06880e https://github.com/OpenSC/OpenSC/commit/13fa934260854840442f02c0fdfed2affd06880e Author: Strykar <294...@us...> Date: 2026-09-03 (Thu, 03 Sep 2026) Changed paths: M src/tools/gids-tool.c M src/tools/sc-hsm-tool.c Log Message: ----------- tools: Check util_getpass return value in sc-hsm-tool and gids-tool util_getpass() returns -1 without assigning *lineptr when tcgetattr() fails, which happens whenever stdout is not a TTY. Every call site in sc-hsm-tool.c and gids-tool.c ignored the return value and used the pointer anyway. In sc-hsm-tool that is a NULL dereference. unwrap_key() does: char *lpin = NULL; util_getpass(&lpin, NULL, stdin); data.pin1.len = strlen(lpin); Reproduce by redirecting stdout on any prompt: printf 'x\n' | sc-hsm-tool --unwrap-key blob.bin --key-reference 3 >log That terminates with SIGSEGV. With this change it prints "Error reading User PIN" and exits 1. The crash precedes PIN verification, so it consumes no retry counter and leaves the card untouched. Check the return at every call site in both files, as pkcs11-tool.c and opensc-explorer.c already do. ask_for_password() gains an int return so it can report the failure to its caller. Commit: bfbf27b6a6b1b1ec3cc87ab72832ee94e6fb3561 https://github.com/OpenSC/OpenSC/commit/bfbf27b6a6b1b1ec3cc87ab72832ee94e6fb3561 Author: Strykar <294...@us...> Date: 2026-09-03 (Thu, 03 Sep 2026) Changed paths: M src/tools/util.c Log Message: ----------- tools: Warn when util_getpass cannot prompt util_getpass() turns off echo on stdout so that a password is not written to the terminal. Where stdout is not a TTY that cannot be done, and the function returned -1 without saying why. The prompt itself had already gone to the redirected stdout, so someone watching the terminal saw nothing and the command simply failed. Print the reason on stderr, which stays visible when stdout is redirected. Suggested-by: Jakub Jelen <jj...@re...> Compare: https://github.com/OpenSC/OpenSC/compare/ad7303040529...bfbf27b6a6b1 To unsubscribe from these emails, change your notification settings at https://github.com/OpenSC/OpenSC/settings/notifications |