From 59348b62e2718a98f805a0e2da97c05972e59888 Mon Sep 17 00:00:00 2001 From: Philipp Storz Date: Thu, 21 Jan 2016 15:03:46 +0100 Subject: [PATCH] ndmp: Add safechecks to bndmp_write_data_to_block When ndmp jobs are canceled, jcr->dcr is null. We now check for that condition and do not dereference then. Fixes #604: Cancel a NDMP Job causes the sd to crash --- src/stored/ndmp_tape.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/stored/ndmp_tape.c b/src/stored/ndmp_tape.c index e4b40a253e4..49d5f136eee 100644 --- a/src/stored/ndmp_tape.c +++ b/src/stored/ndmp_tape.c @@ -343,6 +343,15 @@ static inline bool bndmp_write_data_to_block(JCR *jcr, DCR *dcr = jcr->dcr; POOLMEM *rec_data; + if (!dcr) { + Dmsg0(100, "No dcr defined, bailing out\n"); + return retval; + } + + if (!dcr->rec) { + Dmsg0(100, "No dcr->rec defined, bailing out\n"); + return retval; + } /* * Keep track of the original data buffer and restore it on exit from this function. */