]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix #1364 and #1363 about compression buffer error.
authorEric Bollengier <eric@eb.homelinux.org>
Thu, 3 Sep 2009 06:15:54 +0000 (08:15 +0200)
committerEric Bollengier <eric@eb.homelinux.org>
Thu, 3 Sep 2009 06:15:54 +0000 (08:15 +0200)
bacula/src/filed/restore.c
bacula/src/stored/bextract.c
bacula/technotes

index 808daec84b14a4f5b3867cf85888134df2d57b68..a4ee03a8420849e23b46c04e4205a71684f20415 100644 (file)
@@ -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;
index 1a8c67f542fdc861f9c84c87a9cfbd6bb9de001b..5786a4c133d26b45c19a1749bc9013d760a47759 100644 (file)
@@ -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;
index 718907cb19e7c14a18547ca09b229ad2f161163f..ce88f346483fb0f0c5a354e103f928a970db55b3 100644 (file)
@@ -2,6 +2,8 @@
           
 General:
 
+03Sep09
+ebl  Fix #1364 and #1363 about compression buffer error.
 01Sep09
 kes  Many debug code fixes in regression scripts
 kes  Update tape tests for hardware certification