--- /dev/null
+From aaf17ad370610f17fc998ff9aeb9e6d9e8832787 Mon Sep 17 00:00:00 2001
+From: Eric Bollengier <eric@eb.homelinux.org>
+Date: Wed, 9 Sep 2009 16:46:36 +0200
+Subject: [PATCH 4/4] Fix Exclude Dir Containing ignored when scanning the top_level dir
+
+---
+ bacula/src/findlib/find.c | 2 --
+ bacula/src/findlib/find.h | 1 -
+ bacula/src/findlib/find_one.c | 41 +++++++++++++++++++++++++----------------
+ 3 files changed, 25 insertions(+), 19 deletions(-)
+
+diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c
+index d089b70..38344f3 100644
+--- a/bacula/src/findlib/find.c
++++ b/bacula/src/findlib/find.c
+@@ -274,8 +274,6 @@ static bool accept_file(FF_PKT *ff)
+ basename = ff->fname;
+ }
+
+- ff->ignoredir = incexe->ignoredir;
+-
+ for (j = 0; j < incexe->opts_list.size(); j++) {
+ findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
+ ff->flags = fo->flags;
+diff --git a/bacula/src/findlib/find.h b/bacula/src/findlib/find.h
+index ff9be47..707f529 100644
+--- a/bacula/src/findlib/find.h
++++ b/bacula/src/findlib/find.h
+@@ -215,7 +215,6 @@ struct FF_PKT {
+ uint32_t flags; /* backup options */
+ int GZIP_level; /* compression level */
+ int strip_path; /* strip path count */
+- char *ignoredir; /* ignore directories with this file */
+ bool cmd_plugin; /* set if we have a command plugin */
+ alist fstypes; /* allowed file system types */
+ alist drivetypes; /* allowed drive types */
+diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c
+index 5619ea4..f4f2e7b 100644
+--- a/bacula/src/findlib/find_one.c
++++ b/bacula/src/findlib/find_one.c
+@@ -299,6 +299,29 @@ static bool check_changes(JCR *jcr, FF_PKT *ff_pkt)
+ return true;
+ }
+
++static bool have_ignoredir(FF_PKT *ff_pkt)
++{
++ struct stat sb;
++ char tmp_name[MAXPATHLEN];
++ char *ignoredir = ff_pkt->fileset->incexe->ignoredir;
++
++ if (ignoredir) {
++ if (strlen(ff_pkt->fname) + strlen(ignoredir) + 2 > MAXPATHLEN) {
++ return false;
++ }
++
++ strcpy(tmp_name, ff_pkt->fname);
++ strcat(tmp_name, "/");
++ strcat(tmp_name, ignoredir);
++ if (stat(tmp_name, &sb) == 0) {
++ Dmsg2(100, "Directory '%s' ignored (found %s)\n",
++ ff_pkt->fname, ignoredir);
++ return true; /* Just ignore this directory */
++ }
++ }
++ return false;
++}
++
+ /*
+ * Find a single file.
+ * handle_file is the callback for handling the file.
+@@ -551,22 +574,8 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt,
+ * Ignore this directory and everything below if the file .nobackup
+ * (or what is defined for IgnoreDir in this fileset) exists
+ */
+- if (ff_pkt->ignoredir != NULL) {
+- struct stat sb;
+- char fname[MAXPATHLEN];
+-
+- if (strlen(ff_pkt->fname) + strlen("/") +
+- strlen(ff_pkt->ignoredir) + 1 > MAXPATHLEN)
+- return 1; /* Is this wisdom? */
+-
+- strcpy(fname, ff_pkt->fname);
+- strcat(fname, "/");
+- strcat(fname, ff_pkt->ignoredir);
+- if (stat(fname, &sb) == 0) {
+- Dmsg2(100, "Directory '%s' ignored (found %s)\n",
+- ff_pkt->fname, ff_pkt->ignoredir);
+- return 1; /* Just ignore this directory */
+- }
++ if (have_ignoredir(ff_pkt)) {
++ return 1; /* Just ignore this directory */
+ }
+
+ /* Build a canonical directory name with a trailing slash in link var */
+--
+1.6.3.1
+
--- /dev/null
+commit 6a6cba0ab43be4ba5572b408c3c4fb79352a5273
+Author: Eric Bollengier <eric@eb.homelinux.org>
+Date: Thu Sep 3 08:15:54 2009 +0200
+
+ Fix #1364 and #1363 about compression buffer error.
+
+diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c
+index 808daec..a4ee03a 100644
+--- a/bacula/src/filed/restore.c
++++ b/bacula/src/filed/restore.c
+@@ -207,7 +207,7 @@ void do_restore(JCR *jcr)
+
+ if (have_libz) {
+ uint32_t compress_buf_size = jcr->buf_size + 12 + ((jcr->buf_size+999) / 1000) + 100;
+- jcr->compress_buf = (char *)bmalloc(compress_buf_size);
++ jcr->compress_buf = get_memory(compress_buf_size);
+ jcr->compress_buf_size = compress_buf_size;
+ }
+
+@@ -802,7 +802,7 @@ ok_out:
+ }
+
+ if (jcr->compress_buf) {
+- free(jcr->compress_buf);
++ free_pool_memory(jcr->compress_buf);
+ jcr->compress_buf = NULL;
+ jcr->compress_buf_size = 0;
+ }
+@@ -1007,10 +1007,18 @@ bool decompress_data(JCR *jcr, char **data, uint32_t *length)
+ */
+ compress_len = jcr->compress_buf_size;
+ Dmsg2(200, "Comp_len=%d msglen=%d\n", compress_len, *length);
+- if ((stat=uncompress((Byte *)jcr->compress_buf, &compress_len,
+- (const Byte *)*data, (uLong)*length)) != Z_OK) {
++ while ((stat=uncompress((Byte *)jcr->compress_buf, &compress_len,
++ (const Byte *)*data, (uLong)*length)) == Z_BUF_ERROR)
++ {
++ /* The buffer size is too small, try with a bigger one */
++ compress_len = jcr->compress_buf_size = jcr->compress_buf_size + jcr->compress_buf_size >> 1;
++ Dmsg2(200, "Comp_len=%d msglen=%d\n", compress_len, *length);
++ jcr->compress_buf = check_pool_memory_size(jcr->compress_buf,
++ compress_len);
++ }
++ if (stat != Z_OK) {
+ Qmsg(jcr, M_ERROR, 0, _("Uncompression error on file %s. ERR=%s\n"),
+- jcr->last_fname, zlib_strerror(stat));
++ jcr->last_fname, zlib_strerror(stat));
+ return false;
+ }
+ *data = jcr->compress_buf;
+diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c
+index 1a8c67f..5786a4c 100644
+--- a/bacula/src/stored/bextract.c
++++ b/bacula/src/stored/bextract.c
+@@ -438,9 +438,16 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
+ wbuf = rec->data;
+ wsize = rec->data_len;
+ }
+- compress_len = compress_buf_size;
+- if ((stat=uncompress((Bytef *)compress_buf, &compress_len,
+- (const Bytef *)wbuf, (uLong)wsize) != Z_OK)) {
++
++ while ((stat=uncompress((Byte *)compress_buf, &compress_len,
++ (const Byte *)wbuf, (uLong)wsize)) == Z_BUF_ERROR)
++ {
++ /* The buffer size is too small, try with a bigger one */
++ compress_len = compress_len + compress_len >> 1;
++ compress_buf = check_pool_memory_size(compress_buf,
++ compress_len);
++ }
++ if (stat != Z_OK) {
+ Emsg1(M_ERROR, 0, _("Uncompression error. ERR=%d\n"), stat);
+ extract = false;
+ return true;