]> arthur.barton.de Git - bup.git/commitdiff
index: raise children_n limit to struct 'I' max
authorRob Browning <rlb@defaultvalue.org>
Sat, 5 Mar 2016 17:21:50 +0000 (11:21 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sat, 5 Mar 2016 17:26:28 +0000 (11:26 -0600)
This assertion appears to be a sanity check, and one that's perhaps too
low (think giant Maildirs), so raise it to the real limit, which should
be UINT_MAX, given that the index header containing it is
encoded/decoded via 'I' (platform native unsigned int):

  https://docs.python.org/2/library/struct.html

Since Python doesn't appear to provide access to UINT_MAX, add it (and
INT_MAX) to _helpers.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/_helpers.c
lib/bup/index.py

index 2fe9f280017bcd1f09f70baf65ab08a07bcc18ea..808c728642ae2d0669ecebdb256ec85a294f7592 100644 (file)
@@ -1477,6 +1477,15 @@ PyMODINIT_FUNC init_helpers(void)
 
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wtautological-compare" // For INTEGER_TO_PY().
+    {
+        PyObject *value;
+        value = INTEGER_TO_PY(INT_MAX);
+        PyObject_SetAttrString(m, "INT_MAX", value);
+        Py_DECREF(value);
+        value = INTEGER_TO_PY(UINT_MAX);
+        PyObject_SetAttrString(m, "UINT_MAX", value);
+        Py_DECREF(value);
+    }
 #ifdef HAVE_UTIMENSAT
     {
         PyObject *value;
index 8eabfbbc7bb7fa88353b90abdff113dff7b7e12e..a315e8898811548b980a6bfa14a456101ea71499 100644 (file)
@@ -1,10 +1,10 @@
 import errno, metadata, os, stat, struct, tempfile
 
 from bup import xstat
+from bup._helpers import UINT_MAX
 from bup.helpers import (add_error, log, merge_iter, mmap_readwrite,
                          progress, qprogress, resolve_parent, slashappend)
 
-
 EMPTY_SHA = '\0'*20
 FAKE_SHA = '\x01'*20
 
@@ -324,7 +324,7 @@ class ExistingEntry(Entry):
             dname += '/'
         ofs = self.children_ofs
         assert(ofs <= len(self._m))
-        assert(self.children_n < 1000000)
+        assert(self.children_n <= UINT_MAX)  # i.e. python struct 'I'
         for i in xrange(self.children_n):
             eon = self._m.find('\0', ofs)
             assert(eon >= 0)