]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix #9724 empty EncryptionCommand crash the SD
authorAlain Spineux <alain@baculasystems.com>
Fri, 9 Dec 2022 14:36:57 +0000 (15:36 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:57:00 +0000 (13:57 +0200)
- 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"

bacula/src/stored/autochanger.c
bacula/src/stored/dev.c

index 299d07cbade54e635d5d9e0ce25aa461092d3e5d..f40d06d4adc1d526f1da14c5b893177b4208761b 100644 (file)
@@ -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 == '%') {
index af6fa85250395f5a5835009b0777a66f163d874d..54bd25a29630d4b530ad61244b2c2e98b982d93f 100644 (file)
@@ -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);