1 commit 6a6cba0ab43be4ba5572b408c3c4fb79352a5273
2 Author: Eric Bollengier <eric@eb.homelinux.org>
3 Date: Thu Sep 3 08:15:54 2009 +0200
5 Fix #1364 and #1363 about compression buffer error.
7 diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c
8 index 808daec..a4ee03a 100644
9 --- a/bacula/src/filed/restore.c
10 +++ b/bacula/src/filed/restore.c
11 @@ -207,7 +207,7 @@ void do_restore(JCR *jcr)
14 uint32_t compress_buf_size = jcr->buf_size + 12 + ((jcr->buf_size+999) / 1000) + 100;
15 - jcr->compress_buf = (char *)bmalloc(compress_buf_size);
16 + jcr->compress_buf = get_memory(compress_buf_size);
17 jcr->compress_buf_size = compress_buf_size;
20 @@ -802,7 +802,7 @@ ok_out:
23 if (jcr->compress_buf) {
24 - free(jcr->compress_buf);
25 + free_pool_memory(jcr->compress_buf);
26 jcr->compress_buf = NULL;
27 jcr->compress_buf_size = 0;
29 @@ -1007,10 +1007,18 @@ bool decompress_data(JCR *jcr, char **data, uint32_t *length)
31 compress_len = jcr->compress_buf_size;
32 Dmsg2(200, "Comp_len=%d msglen=%d\n", compress_len, *length);
33 - if ((stat=uncompress((Byte *)jcr->compress_buf, &compress_len,
34 - (const Byte *)*data, (uLong)*length)) != Z_OK) {
35 + while ((stat=uncompress((Byte *)jcr->compress_buf, &compress_len,
36 + (const Byte *)*data, (uLong)*length)) == Z_BUF_ERROR)
38 + /* The buffer size is too small, try with a bigger one */
39 + compress_len = jcr->compress_buf_size = jcr->compress_buf_size + jcr->compress_buf_size >> 1;
40 + Dmsg2(200, "Comp_len=%d msglen=%d\n", compress_len, *length);
41 + jcr->compress_buf = check_pool_memory_size(jcr->compress_buf,
45 Qmsg(jcr, M_ERROR, 0, _("Uncompression error on file %s. ERR=%s\n"),
46 - jcr->last_fname, zlib_strerror(stat));
47 + jcr->last_fname, zlib_strerror(stat));
50 *data = jcr->compress_buf;
51 diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c
52 index 1a8c67f..5786a4c 100644
53 --- a/bacula/src/stored/bextract.c
54 +++ b/bacula/src/stored/bextract.c
55 @@ -438,9 +438,16 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
57 wsize = rec->data_len;
59 - compress_len = compress_buf_size;
60 - if ((stat=uncompress((Bytef *)compress_buf, &compress_len,
61 - (const Bytef *)wbuf, (uLong)wsize) != Z_OK)) {
63 + while ((stat=uncompress((Byte *)compress_buf, &compress_len,
64 + (const Byte *)wbuf, (uLong)wsize)) == Z_BUF_ERROR)
66 + /* The buffer size is too small, try with a bigger one */
67 + compress_len = compress_len + compress_len >> 1;
68 + compress_buf = check_pool_memory_size(compress_buf,
72 Emsg1(M_ERROR, 0, _("Uncompression error. ERR=%d\n"), stat);