v1-avoid-overflow-with-simplehash-start-iterate.patch
application/octet-stream
Filename: v1-avoid-overflow-with-simplehash-start-iterate.patch
Type: application/octet-stream
Part: 0
Message:
Re: Avoid overflow with simplehash
Patch
Format: unified
Series: patch v1
| File | + | − |
|---|---|---|
| src/include/lib/simplehash.h | 4 | 3 |
diff --git a/src/include/lib/simplehash.h b/src/include/lib/simplehash.h
index 48db837ec8..4fe627a921 100644
--- a/src/include/lib/simplehash.h
+++ b/src/include/lib/simplehash.h
@@ -964,8 +964,8 @@ SH_DELETE_ITEM(SH_TYPE * tb, SH_ELEMENT_TYPE * entry)
SH_SCOPE void
SH_START_ITERATE(SH_TYPE * tb, SH_ITERATOR * iter)
{
- int i;
- uint64 startelem = PG_UINT64_MAX;
+ uint32 i;
+ uint32 startelem = PG_UINT32_MAX;
/*
* Search for the first empty element. As deletions during iterations are
@@ -983,7 +983,8 @@ SH_START_ITERATE(SH_TYPE * tb, SH_ITERATOR * iter)
}
}
- Assert(startelem < SH_MAX_SIZE);
+ /* We should have found an empty element */
+ Assert(startelem < SH_SIZE_MAX);
/*
* Iterate backwards, that allows the current element to be deleted, even