]> git.draconx.ca Git - upkg.git/commitdiff
music: Check data size against actual file size.
authorNick Bowler <nbowler@draconx.ca>
Sun, 20 May 2012 04:08:12 +0000 (00:08 -0400)
committerNick Bowler <nbowler@draconx.ca>
Sun, 20 May 2012 04:08:12 +0000 (00:08 -0400)
Blindly setting the file size to something potentially larger than it
seems outright silly.  All this mucking about with the upkg_file struct
members should probably be eliminated eventually, but may as well do it
sanely for now.

src/engine/music.gob

index b4ed7d2db1724a22027ae4abe37862c84986d36f..f0bde09f4ace15b4aa0c48225e245c03e13afa67 100644 (file)
@@ -108,7 +108,6 @@ class Engine:Music from U:Object (dynamic)
        override (U:Object) int deserialize(U:Object *uo)
        {
                struct upkg_file *f = uo->pkg_file;
-               Self *self = SELF(uo);
                size_t rc, pos = 0, buflen;
                unsigned char buf[32];
                long size;
@@ -130,7 +129,7 @@ class Engine:Music from U:Object (dynamic)
                }
 
                rc = upkg_decode_index(&size, buf+pos, buflen-pos);
-               if (rc == 0 || size < 0)
+               if (rc == 0 || size < 0 || size > f->len - pos)
                        return -1;
                pos += rc;