GNU bug report logs - #43583
[PATCH 0/4] Fix DFLTCC segfault when compressing or decompressing two files

Previous Next

Package: gzip;

Reported by: Ilya Leoshkevich <iii <at> linux.ibm.com>

Date: Wed, 23 Sep 2020 22:10:02 UTC

Severity: normal

Tags: patch

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ilya Leoshkevich <iii <at> linux.ibm.com>
To: Jim Meyering <meyering <at> fb.com>, Paul Eggert <eggert <at> cs.ucla.edu>
Cc: Ilya Leoshkevich <iii <at> linux.ibm.com>, bug-gzip <at> gnu.org
Subject: [PATCH 3/4] Fix DFLTCC segfault when compressing or decompressing two
 files
Date: Thu, 24 Sep 2020 00:08:56 +0200
The value in total_in global variable from processing the first file
affected processing of the second file.  Fix by making total_in local.
---
 dfltcc.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/dfltcc.c b/dfltcc.c
index 86aa56e..3a5b92d 100644
--- a/dfltcc.c
+++ b/dfltcc.c
@@ -242,10 +242,8 @@ dfltcc_gdht (struct dfltcc_param_v0 *param)
   dfltcc (DFLTCC_GDHT, param, NULL, NULL, &next_in, &avail_in, NULL);
 }
 
-static off_t total_in;
-
 static dfltcc_cc
-dfltcc_cmpr_xpnd (struct dfltcc_param_v0 *param, int fn)
+dfltcc_cmpr_xpnd (struct dfltcc_param_v0 *param, int fn, off_t *total_in)
 {
   uch *next_out = outbuf + outcnt;
   size_t avail_out = OUTBUFSIZ - outcnt;
@@ -257,7 +255,7 @@ dfltcc_cmpr_xpnd (struct dfltcc_param_v0 *param, int fn)
                          window);
   off_t consumed_in = next_in - (inbuf + inptr);
   inptr += consumed_in;
-  total_in += consumed_in;
+  *total_in += consumed_in;
   outcnt += ((OUTBUFSIZ - outcnt) - avail_out);
   return cc;
 }
@@ -349,6 +347,7 @@ dfltcc_deflate (int pack_level)
 
   union aligned_dfltcc_param_v0 ctx_v0;
   struct dfltcc_param_v0 *param = init_param (&ctx_v0);
+  off_t total_in = 0;
 
   /* Compress ifd into ofd in a loop.  */
   while (true)
@@ -398,7 +397,8 @@ dfltcc_deflate (int pack_level)
         }
 
       /* Compress inbuf into outbuf.  */
-      while (dfltcc_cmpr_xpnd (param, DFLTCC_CMPR) == DFLTCC_CC_AGAIN)
+      while (dfltcc_cmpr_xpnd (param, DFLTCC_CMPR, &total_in)
+             == DFLTCC_CC_AGAIN)
         ;
 
       /* Unmask the input data.  */
@@ -427,6 +427,7 @@ dfltcc_inflate (void)
 
   union aligned_dfltcc_param_v0 ctx_v0;
   struct dfltcc_param_v0 *param = init_param (&ctx_v0);
+  off_t total_in = 0;
 
   /* Decompress ifd into ofd in a loop.  */
   while (true)
@@ -446,7 +447,8 @@ dfltcc_inflate (void)
 
         /* Decompress inbuf into outbuf.  */
         dfltcc_cc cc;
-        while ((cc = dfltcc_cmpr_xpnd (param, DFLTCC_XPND)) == DFLTCC_CC_AGAIN)
+        while ((cc = dfltcc_cmpr_xpnd (param, DFLTCC_XPND, &total_in))
+               == DFLTCC_CC_AGAIN)
           ;
         if (cc == DFLTCC_CC_OK)
           {
-- 
2.25.4





This bug report was last modified 3 years and 341 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.