The previous calculation was wrong, noticed when testing on a 32-bit
host. Fix it and include the invalid value in the error message.
Thanks to Johannes Berg for help with diagnosis.
Signed-off-by: Rob Browning <
r...@defaultvalue.org>
Tested-by: Rob Browning <
r...@defaultvalue.org>
---
Pushed to main.
lib/bup/_hashsplit.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/bup/_hashsplit.c b/lib/bup/_hashsplit.c
index ea6151b8..a101cef0 100644
--- a/lib/bup/_hashsplit.c
+++ b/lib/bup/_hashsplit.c
@@ -344,8 +344,9 @@ static int HashSplitter_init(HashSplitter *self, PyObject *args, PyObject *kwds)
goto error;
}
- if (self->bits >= (log2(sizeof(self->max_blob)) * 8) - 2) {
- PyErr_Format(PyExc_ValueError, "bits value is too large");
+ if (self->bits >= sizeof(self->max_blob) * 8 - 2) {
+ PyErr_Format(PyExc_ValueError, "bits value is too large: %u",
+ self->bits);
goto error;
}
self->max_blob = 1 << (self->bits + 2);
@@ -723,7 +724,7 @@ static int RecordHashSplitter_init(RecordHashSplitter *self, PyObject *args, PyO
return -1;
// Same as the file splitter's max_blob
- if (self->bits >= (log2(sizeof(self->max_split_size)) * 8) - 2) {
+ if (self->bits >= sizeof(self->max_split_size) * 8 - 2) {
PyErr_Format(PyExc_ValueError, "bits value is too large");
return -1;
}
--
2.47.3