Panu Matilainen f3f6be
commit bd96c179b79fce627403804ad6c236c783aca478
Panu Matilainen f3f6be
Author: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen f3f6be
Date:   Fri Jan 21 14:02:28 2011 +0200
Panu Matilainen f3f6be
Panu Matilainen f3f6be
    Plug potential division by zero in the rpmdb size calculation (RhBug:671056)
Panu Matilainen f3f6be
    - This smells like treating the symptom instead of the disease, add
Panu Matilainen f3f6be
      a reminder comment to figure out what's going on here...
Panu Matilainen f3f6be
Panu Matilainen f3f6be
diff --git a/lib/transaction.c b/lib/transaction.c
Panu Matilainen f3f6be
index ed6f738..06e54af 100644
Panu Matilainen f3f6be
--- a/lib/transaction.c
Panu Matilainen f3f6be
+++ b/lib/transaction.c
Panu Matilainen f3f6be
@@ -246,7 +246,8 @@ static void rpmtsUpdateDSIrpmDBSize(const rpmte p,
Panu Matilainen f3f6be
     rpm_loff_t headerSize;
Panu Matilainen f3f6be
     int64_t bneeded;
Panu Matilainen f3f6be
 
Panu Matilainen f3f6be
-    if (dsi==NULL) return;
Panu Matilainen f3f6be
+    /* XXX somehow we can end up here with bsize 0 (RhBug:671056) */
Panu Matilainen f3f6be
+    if (dsi == NULL || dsi->bsize == 0) return;
Panu Matilainen f3f6be
 
Panu Matilainen f3f6be
     headerSize = rpmteHeaderSize(p);
Panu Matilainen f3f6be
     bneeded = BLOCK_ROUND(headerSize, dsi->bsize);