Fix dribble length calculation on headerLoad()
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 24 Nov 2011 08:44:14 +0000 (10:44 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 24 Nov 2011 09:12:03 +0000 (11:12 +0200)
- When calculating length of dribbles, we need to take into account the
  size up to that point, otherwise the alignment can be wrong causing
  the sizes not to add up.
- With that mystery solved, we can now make the final length check
  as strict as it should be.

lib/header.c

index 8fafc86..c3ecc87 100644 (file)
@@ -866,13 +866,12 @@ Header headerLoad(void * uh)
            indexEntry newEntry = entry + ril;
            int ne = (h->indexUsed - ril);
            int rid = entry->info.offset+1;
-           int rc;
 
            /* Load dribble entries from region. */
-           rc = regionSwab(newEntry, ne, 0, pe+ril, dataStart, dataEnd, rid);
-           if (rc < 0)
+           rdlen = regionSwab(newEntry, ne, rdlen, pe+ril,
+                               dataStart, dataEnd, rid);
+           if (rdlen < 0)
                goto errxit;
-           rdlen += rc;
 
          { indexEntry firstEntry = newEntry;
            int save = h->indexUsed;
@@ -896,8 +895,8 @@ Header headerLoad(void * uh)
        }
 
        rdlen += REGION_TAG_COUNT;
-       /* XXX should be equality test, but dribbles are sometimes a bit off? */
-       if (rdlen > dl || (rdlen < dl && ril == h->indexUsed))
+
+       if (rdlen != dl)
            goto errxit;
     }