From: Alain Spineux Date: Fri, 9 Dec 2022 14:36:57 +0000 (+0100) Subject: Fix #9724 empty EncryptionCommand crash the SD X-Git-Tag: Beta-15.0.0~325 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9bdf80490896563d06277e79d1ad280839797ad;p=thirdparty%2Fbacula.git Fix #9724 empty EncryptionCommand crash the SD - fix edit_device_codes() to handle NULL has empty format string - test for empty EncryptionCommand at runtime and report a FATAL error. tested for "label" and "run" --- diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index 299d07cba..f40d06d4a 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -737,7 +737,10 @@ void edit_device_codes(DCR *dcr, POOLMEM **omsg, const char *imsg, const char *c const char *str; char add[20]; - **omsg = 0; + **omsg = '\0'; + if (imsg == NULL) { + return; + } Dmsg1(1800, "edit_device_codes: %s\n", imsg); for (p=imsg; *p; p++) { if (*p == '%') { diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index af6fa8525..54bd25a29 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -1202,7 +1202,13 @@ bool DEVICE::load_encryption_key(DCR *dcr, const char *operation, } if (device->volume_encryption == ET_NO || (op != op_label && !(VolHdr.blkh_options & BLKHOPT_ENCRYPT_VOL))) { - return ok; + return true; /* No error */ + } + if (me->encryption_command == NULL || me->encryption_command[0] == '\0') { + if (jcr == NULL || !jcr->is_job_canceled()) { + Jmsg0(jcr, M_FATAL, 0, _("The \"Encryption Command\" is empty, impossible to call the key-manager program\n")); + } + return false; /* error */ } POOLMEM *encrypt_program = get_pool_memory(PM_FNAME); POOL_MEM results(PM_MESSAGE);