Browse code

fix race introduced in r4379

git-svn: trunk@4844

aCaB authored on 2009/02/21 18:51:42
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Sat Feb 21 11:22:15 CET 2009 (acab)
2
+-----------------------------------
3
+ * libclamav/nsis: fix race introduced in r4379
4
+
1 5
 Sat Feb 21 10:55:30 CET 2009 (acab)
2 6
 -----------------------------------
3 7
  * build system: Allow to link to system libtommath.
... ...
@@ -143,9 +143,9 @@ const unsigned short *e,         /* list of extra bits for non-simple codes */
143 143
 inflate_huft * FAR *t,  /* result: starting table */
144 144
 uIntf *m,               /* maximum lookup bits, returns actual */
145 145
 inflate_huft *hp,       /* space for trees */
146
-uInt *hn)               /* working area: values in order of bit length */
146
+uInt *hn,               /* working area: values in order of bit length */
147
+uIntf *v)             /* work area for huft_build */
147 148
 {
148
-  static uIntf v[288];             /* work area for huft_build */
149 149
   uInt a;                       /* counter for codes of length k */
150 150
   uInt c[BMAX+1];               /* bit length count table */
151 151
   uInt f;                       /* i repeats in table every f entries */
... ...
@@ -382,8 +382,7 @@ int ZEXPORT nsis_inflate(nsis_z_streamp z)
382 382
             {
383 383
               int _k;              /* temporary variable */
384 384
               uInt f = 0;         /* number of hufts used in fixed_mem */
385
-              static uIntf lc[288];           /* length list for huft_build */
386
-
385
+              
387 386
               /* literal table */
388 387
               for (_k = 0; _k < 288; _k++)
389 388
               {
... ...
@@ -393,15 +392,15 @@ int ZEXPORT nsis_inflate(nsis_z_streamp z)
393 393
                   if (_k < 256) v++;
394 394
                   else if (_k < 280) v--;
395 395
                 }
396
-                lc[_k] = v;
396
+                s->zs.lc[_k] = v;
397 397
               }
398 398
 
399
-              huft_build(lc, 288, 257, cplens, cplext, &s->zs.fixed_tl, &s->zs.fixed_bl, s->zs.fixed_mem, &f);
399
+              huft_build(s->zs.lc, 288, 257, cplens, cplext, &s->zs.fixed_tl, &s->zs.fixed_bl, s->zs.fixed_mem, &f, s->zs.v);
400 400
 
401 401
               /* distance table */
402
-              for (_k = 0; _k < 30; _k++) lc[_k] = 5;
402
+              for (_k = 0; _k < 30; _k++) s->zs.lc[_k] = 5;
403 403
 
404
-              huft_build(lc, 30, 0, cpdist, cpdext, &s->zs.fixed_td, &s->zs.fixed_bd, s->zs.fixed_mem, &f);
404
+              huft_build(s->zs.lc, 30, 0, cpdist, cpdext, &s->zs.fixed_td, &s->zs.fixed_bd, s->zs.fixed_mem, &f, s->zs.v);
405 405
 
406 406
               /* done */
407 407
               s->zs.fixed_built++;
... ...
@@ -476,7 +475,7 @@ int ZEXPORT nsis_inflate(nsis_z_streamp z)
476 476
         uInt hn = 0;          /* hufts used in space */
477 477
 
478 478
         t = huft_build(s->sub.trees.t_blens, 19, 19, Z_NULL, Z_NULL,
479
-		       &s->sub.trees.tb, &s->sub.trees.bb, s->hufts, &hn);
479
+		       &s->sub.trees.tb, &s->sub.trees.bb, s->hufts, &hn, s->zs.v);
480 480
         if (t != Z_OK || !s->sub.trees.bb)
481 481
         {
482 482
           s->mode = NZ_BAD;
... ...
@@ -548,12 +547,12 @@ int ZEXPORT nsis_inflate(nsis_z_streamp z)
548 548
         bl = 9;         /* must be <= 9 for lookahead assumptions */
549 549
         bd = 6;         /* must be <= 9 for lookahead assumptions */
550 550
 
551
-        t = huft_build(s->sub.trees.t_blens, nl, 257, cplens, cplext, &tl, &bl, s->hufts, &hn);
551
+        t = huft_build(s->sub.trees.t_blens, nl, 257, cplens, cplext, &tl, &bl, s->hufts, &hn, s->zs.v);
552 552
         if (bl == 0) t = Z_DATA_ERROR;
553 553
         if (t == Z_OK)
554 554
         {
555 555
           /* build distance tree */
556
-          t = huft_build(s->sub.trees.t_blens + nl, nd, 0, cpdist, cpdext, &td, &bd, s->hufts, &hn);
556
+          t = huft_build(s->sub.trees.t_blens + nl, nd, 0, cpdist, cpdext, &td, &bd, s->hufts, &hn, s->zs.v);
557 557
         }
558 558
         if (t != Z_OK || (bd == 0 && nl > 257))
559 559
         {
... ...
@@ -116,6 +116,8 @@ struct z_stuff {
116 116
   uInt fixed_bd;
117 117
   inflate_huft *fixed_tl;
118 118
   inflate_huft *fixed_td;
119
+  uIntf v[288];
120
+  uIntf lc[288];
119 121
 };
120 122
 
121 123
 struct inflate_blocks_state {