[gcab] Fix a theoretical crash when building the table entries



commit 6190af8dcf10bcb0d3e44f292f0fc806a811bd9e
Author: Richard Hughes <richard hughsie com>
Date:   Wed Mar 1 17:02:05 2017 +0000

    Fix a theoretical crash when building the table entries
    
    I can't actually see a way to construct the ZIPstate with no tables, but this
    at least this stops Coverity complaining.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779462

 libgcab/decomp.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/libgcab/decomp.c b/libgcab/decomp.c
index cce368e..52445e8 100644
--- a/libgcab/decomp.c
+++ b/libgcab/decomp.c
@@ -248,6 +248,10 @@ struct Ziphuft **t, cab_LONG *m, fdi_decomp_state *decomp_state)
         i ^= j;
       i ^= j;
 
+      /* no tables */
+      if (h < 0)
+        return 2;               /* corrupt */
+
       /* backup over finished tables */
       while ((i & ((1 << w) - 1)) != ZIP(x)[h])
         w -= l[--h];            /* don't need to update q */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]