Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

Version 0.1.2 (unreleased)
--------------------------

- Require ``key_size >= 4`` to avoid out-of-bounds reads in ``_get_index``, #42.

Version 0.1.1 (2026-02-09)
--------------------------

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Memory-efficient hash table (implemented in Cython)"
requires-python = ">=3.10"
keywords = ["hashtable", "memory", "efficient", "dense"]
classifiers = [
"Development Status :: 3 - Alpha",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
Expand Down
4 changes: 2 additions & 2 deletions src/borghash/HashTable.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ cdef class HashTable:
# .keys and .values array.
# the keys/values arrays have bigger elements and are not hash tables, thus collisions and load
# factor are no concern there. the kv_grow_factor can be relatively small.
if not key_size:
raise ValueError("key_size must be specified and must be > 0.")
if key_size < 4:
raise ValueError("key_size must be specified and must be >= 4.")
if not value_size:
raise ValueError("value_size must be specified and must be > 0.")
self.ksize = key_size
Expand Down
4 changes: 2 additions & 2 deletions src/borghash/HashTableNT.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ cdef class HashTableNT:
def __init__(self, items=None, *,
key_size: int, value_type: Any, value_format: Any,
capacity: int = MIN_CAPACITY, byte_order="little") -> None:
if not isinstance(key_size, int) or not key_size > 0:
raise ValueError("key_size must be an integer and > 0.")
if not isinstance(key_size, int) or not key_size >= 4:
raise ValueError("key_size must be an integer and >= 4.")
if type(value_type) is not type:
raise TypeError("value_type must be a namedtuple type.")
if not isinstance(value_format, tuple):
Expand Down
Loading