[ZODB-Dev] Integer Overflow on new pack impl

Sidnei da Silva sidnei at x3ng.com
Tue May 20 11:10:07 EDT 2003


On Mon, May 19, 2003 at 07:55:27PM -0400, Tim Peters wrote:
| Thanks for the diagnosis!  That should do the trick.  By way of explanation
| (although not excuse), the new pack code was backported from ZODB4, which
| requires Python 2.2 or later.  When an integer operation overflows a
| (Python) short int in 2.2, it automatically produces the correct Python
| long-int result -- integer overflow just doesn't happen anymore, so none of
| the largefile tests we ran under ZODB4 could have provoked this bug.  Alas,
| I don't believe we have any giant-file pack tests that run as part of the
| std test suite, and that left a hole that we tripped over here.

Almost did the trick. I had to change another initialization of 'pos'
a few lines below. Attached is the patch.

-- 
Sidnei da Silva (dreamcatcher) <sidnei at x3ng.com.br>
X3ng Web Technology <http://www.x3ng.com.br>
GNU/Linux user 257852
Debian GNU/Linux 3.0 (Sid) 2.4.18 ppc

Oh, I've seen copies [of Linux Journal] around the terminal room at The Labs.
	-- Dennis Ritchie
-------------- next part --------------
Index: lib/python/ZODB/fspack.py
===================================================================
RCS file: /cvs-repository/Zope/lib/python/ZODB/fspack.py,v
retrieving revision 1.5.4.2
diff -u -r1.5.4.2 fspack.py
--- lib/python/ZODB/fspack.py	20 May 2003 12:58:21 -0000	1.5.4.2
+++ lib/python/ZODB/fspack.py	20 May 2003 13:03:47 -0000
@@ -465,7 +465,7 @@
         del self.oid2curpos
 
     def buildPackIndex(self):
-        pos = 4
+        pos = 4L
         while pos < self.eof:
             th = self._read_txn_header(pos)
             if th.tid > self.packtime:
@@ -711,7 +711,7 @@
 
     def copyToPacktime(self):
         offset = 0L  # the amount of space freed by packing
-        pos = self._metadata_size
+        pos = 0L + self._metadata_size
         new_pos = pos
 
         while pos < self.gc.packpos:


More information about the ZODB-Dev mailing list