Skip to content

Commit

Permalink
console: reset a pointer variable after free
Browse files Browse the repository at this point in the history
    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
  • Loading branch information
franku committed Jul 15, 2019
1 parent 1252880 commit 9f24d0d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/console/auth_pam.cc
Expand Up @@ -109,13 +109,17 @@ bool ConsolePamAuthenticate(FILE* std_in, BareosSocket* UA_sock)
case PamAuthState::SEND_INPUT: case PamAuthState::SEND_INPUT:
UA_sock->fsend(userinput); UA_sock->fsend(userinput);
free(userinput); free(userinput);
userinput = nullptr;
state = PamAuthState::INIT; state = PamAuthState::INIT;
break; break;
default: default:
break; break;
} }
if (UA_sock->IsStop() || UA_sock->IsError()) { if (UA_sock->IsStop() || UA_sock->IsError()) {
if (userinput) { free(userinput); } if (userinput) {
free(userinput);
userinput = nullptr;
}
error = true; error = true;
break; break;
} }
Expand Down

0 comments on commit 9f24d0d

Please sign in to comment.