From 7ae93ed8df0676be12bfab51ed101b3c127e9d89 Mon Sep 17 00:00:00 2001 From: Landon Fuller Date: Sun, 29 Apr 2007 18:27:32 +0000 Subject: [PATCH] Sanity check the encryption context before attempting to use it. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4660 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/filed/restore.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index bb1f27a9c9..08b678cf6e 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -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; } } -- 2.39.5