]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Exit if out of data or any error detected.
authorToni Wilen <twilen@winuae.net>
Thu, 9 Apr 2020 11:11:31 +0000 (14:11 +0300)
committerToni Wilen <twilen@winuae.net>
Thu, 9 Apr 2020 11:11:31 +0000 (14:11 +0300)
archivers/wrp/warp.cpp

index 204235a0a2dfb1ce39df4084c1a1b579abe544ff..6b9f94ef4f5fea5e696ba28e17dc5ab0066e87d4 100644 (file)
@@ -95,6 +95,9 @@ static uae_s32 ARCunsqueeze(struct zfile *in, struct zfile *out, struct rledata
        {
                numnodes = xadIOGetBitsLow(&io, 16);
 
+               if (io.err)
+                       return XADERR_ILLEGALDATA;
+
                if(numnodes < 0 || numnodes >= ARCSQNUMVALS)
                        err = XADERR_DECRUNCH;
                else
@@ -115,6 +118,9 @@ static uae_s32 ARCunsqueeze(struct zfile *in, struct zfile *out, struct rledata
                                while(i >= 0 && !io.err)
                                        i = node[2*i + xadIOGetBitsLow(&io, 1)];
 
+                               if (io.err)
+                                       return XADERR_ILLEGALDATA;
+
                                i = -(i + 1); /* decode fake node index to original data value */
 
                                if(i != ARCSQSPEOF)
@@ -441,8 +447,12 @@ struct zfile *unwarp(struct zfile *zf)
                        {
                                int i;
                                for (i = 0; i < size; i++) {
-                                       uae_u8 v = zfile_getc (zf);
-                                       putrle (v, tmpf, algo == 3 ? &rled : NULL);
+                                       uae_s32 v = zfile_getc(zf);
+                                       if (v == -1) {
+                                               err = XADERR_ILLEGALDATA;
+                                               break;
+                                       }
+                                       putrle((uae_u8)v, tmpf, algo == 3 ? &rled : NULL);
                                }
                        }
                        break;