]> git.sur5r.net Git - bacula/bacula/commitdiff
Sanity check the encryption context before attempting to use it.
authorLandon Fuller <landonf@opendarwin.org>
Sun, 29 Apr 2007 18:27:32 +0000 (18:27 +0000)
committerLandon Fuller <landonf@opendarwin.org>
Sun, 29 Apr 2007 18:27:32 +0000 (18:27 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4660 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/filed/restore.c

index bb1f27a9c91543cabf2726cab5255e4f7637ecb9..08b678cf6ec0c5e4c5116d0f911c6b5926861dc8 100644 (file)
@@ -470,6 +470,12 @@ void do_restore(JCR *jcr)
                   || stream == STREAM_ENCRYPTED_FILE_GZIP_DATA
                   || stream == STREAM_ENCRYPTED_WIN32_DATA
                   || stream == STREAM_ENCRYPTED_WIN32_GZIP_DATA) {
+               if (!cipher_ctx.cipher) {
+                  Jmsg1(jcr, M_ERROR, 0, _("Missing encryption session data stream for %s\n"), jcr->last_fname);
+                  extract = false;
+                  bclose(&bfd);
+                  continue;
+               }
                flags |= FO_ENCRYPT;
             }
 
@@ -499,12 +505,20 @@ void do_restore(JCR *jcr)
             alt_flags |= FO_ENCRYPT;
 
             /* Set up a decryption context */
-            if (!alt_cipher_ctx.cipher) {
+            if (extract && !alt_cipher_ctx.cipher) {
+               if (!cs) {
+                  Jmsg1(jcr, M_ERROR, 0, _("Missing encryption session data stream for %s\n"), jcr->last_fname);
+                  extract = false;
+                  bclose(&bfd);
+                  continue;
+               }
+
                if ((alt_cipher_ctx.cipher = crypto_cipher_new(cs, false, &alt_cipher_ctx.block_size)) == NULL) {
                   Jmsg1(jcr, M_ERROR, 0, _("Failed to initialize decryption context for %s\n"), jcr->last_fname);
                   crypto_session_free(cs);
                   cs = NULL;
                   extract = false;
+                  bclose(&bfd);
                   continue;
                }
             }