From 9f24d0dbf332696a8a7785e8bb0276b43c7c1522 Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Fri, 12 Jul 2019 16:36:49 +0200 Subject: [PATCH] console: reset a pointer variable after free fixes #1100: bconsole crashes when a pam authentication aborts This fixes a double free of a pointer when the called pam module aborts the authentication i.e. in case of an error --- core/src/console/auth_pam.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/console/auth_pam.cc b/core/src/console/auth_pam.cc index ae9a844bb6b..f9956f103e8 100644 --- a/core/src/console/auth_pam.cc +++ b/core/src/console/auth_pam.cc @@ -109,13 +109,17 @@ bool ConsolePamAuthenticate(FILE* std_in, BareosSocket* UA_sock) case PamAuthState::SEND_INPUT: UA_sock->fsend(userinput); free(userinput); + userinput = nullptr; state = PamAuthState::INIT; break; default: break; } if (UA_sock->IsStop() || UA_sock->IsError()) { - if (userinput) { free(userinput); } + if (userinput) { + free(userinput); + userinput = nullptr; + } error = true; break; }