]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix #7998 About dir crashing for client intiated backup
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Fri, 6 Aug 2021 21:40:59 +0000 (23:40 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:03 +0000 (09:03 +0100)
Description:
For client initiated backup, ua->UA_sock == jcr->file_bsock, see
(ua_run.c:275):
if (rc.fdcalled) {
      jcr->file_bsock = ua->UA_sock;
      jcr->file_bsock->set_jcr(jcr);
}

So when jcr is freed, the ua->UA_sock which is used by ua->error_msg
and others, is no longer valid.

bacula/src/dird/ua_run.c

index 929e8a489222e8455ccf06305aac832a66059c62..fa83f8e161b34790a6dd14a7da41c0c3827b1add 100644 (file)
@@ -303,13 +303,15 @@ static JobId_t start_job(UAContext *ua, JCR *jcr, run_ctx &rc)
    }
    Dmsg4(100, "JobId=%u NewJobId=%d pool=%s priority=%d\n", (int)jcr->JobId,
          JobId, jcr->pool->name(), jcr->JobPriority);
-   free_jcr(jcr);                  /* release jcr */
    if (JobId == 0) {
       ua->error_msg(_("Job %s failed.\n"), edit_int64(rc.jr.JobId, ed1));
 
    } else {
       ua->send_msg(_("Job queued. JobId=%s\n"), edit_int64(JobId, ed1));
    }
+
+   free_jcr(jcr);                  /* release jcr */
+
    if (rc.fdcalled) {
       ua->signal(BNET_FDCALLED); /* After this point, this is a new connection */
       ua->UA_sock = new_bsock();