From 22a8e3c307830c728d01b21d91a581ab8efe8155 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 2 Jul 2020 08:00:00 +0000 Subject: misc_conv: fix potential information leak on error path * libpam_misc/misc_conv.c (read_string): Clear the stack buffer from data read earlier from stdin in case of a read error. --- libpam_misc/misc_conv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libpam_misc') diff --git a/libpam_misc/misc_conv.c b/libpam_misc/misc_conv.c index 70b96454..35610e05 100644 --- a/libpam_misc/misc_conv.c +++ b/libpam_misc/misc_conv.c @@ -184,8 +184,10 @@ static int read_string(int echo, const char *prompt, char **retstr) nc++) { int rv; if ((rv=read(STDIN_FILENO, line+nc, 1)) != 1) { - if (rv < 0) + if (rv < 0) { + _pam_overwrite_n(line, (unsigned int) nc); nc = rv; + } break; } } -- cgit v1.2.3