Skip to content

Commit

Permalink
tls: fix nullpointer reference if jcr is nullpointer
Browse files Browse the repository at this point in the history
For the suppression of double error messages we now verify
that jcr is not null before dereferencing it.
  • Loading branch information
pstorz authored and franku committed Oct 1, 2018
1 parent 0539be3 commit eed9ddc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/src/dird/fd_cmds.cc
Expand Up @@ -182,7 +182,7 @@ static void OutputMessageForConnectionTry(JobControlRecord *jcr, UaContext *ua)
break;
}

if (jcr->JobId != 0) {
if (jcr && jcr->JobId != 0) {
Jmsg(jcr, M_INFO, 0, m.c_str());
}
if (ua) {
Expand All @@ -204,7 +204,7 @@ static void SendInfoChosenCipher(JobControlRecord *jcr, UaContext *ua)

static void SendInfoFailed(JobControlRecord *jcr, UaContext *ua)
{
if (jcr->JobId != 0) {
if (jcr && jcr->JobId != 0) {
Jmsg(jcr, M_INFO, 0, "Failed");
}
if (ua) { /* only whith console connection */
Expand Down
4 changes: 2 additions & 2 deletions core/src/lib/bsock.cc
Expand Up @@ -573,7 +573,7 @@ bool BareosSocket::DoTlsHandshakeWithClient(TlsConfigBase *selected_local_tls, J
if (BnetTlsServer(this, verify_list)) {
return true;
}
if (jcr->JobId != 0) {
if (jcr && jcr->JobId != 0) {
Jmsg(jcr, M_FATAL, 0, _("TLS negotiation failed.\n"));
}
Dmsg0(debuglevel, "TLS negotiation failed.\n");
Expand All @@ -589,7 +589,7 @@ bool BareosSocket::DoTlsHandshakeWithServer(TlsConfigBase *selected_local_tls,
selected_local_tls->AllowedCertificateCommonNames())) {
return true;
}
if (jcr->JobId != 0) {
if (jcr && jcr->JobId != 0) {
Jmsg(jcr, M_FATAL, 0, _("TLS negotiation failed.\n"));
}
Dmsg0(debuglevel, "TLS negotiation failed.\n");
Expand Down

0 comments on commit eed9ddc

Please sign in to comment.