Skip to content

Commit

Permalink
pythongh-74573: document that ndbm can silently corrupt databases on …
Browse files Browse the repository at this point in the history
…macOS (python#113354)

* pythongh-74573: document that ndbm can silently corrupt databases on macOS

The system ndbm implementation on macOS has an undocumented limitation
on the size of values and can silently corrupt database files when those
are exceeded.

Co-authored-by: Erlend E. Aasland <[email protected]>
  • Loading branch information
2 people authored and Glyphack committed Jan 27, 2024
1 parent c853819 commit 589da93
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Doc/library/dbm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ This module can be used with the "classic" ndbm interface or the GNU GDBM
compatibility interface. On Unix, the :program:`configure` script will attempt
to locate the appropriate header file to simplify building this module.

.. warning::

The ndbm library shipped as part of macOS has an undocumented limitation on the
size of values, which can result in corrupted database files
when storing values larger than this limit. Reading such corrupted files can
result in a hard crash (segmentation fault).

.. exception:: error

Raised on :mod:`dbm.ndbm`-specific errors, such as I/O errors. :exc:`KeyError` is raised
Expand Down
3 changes: 3 additions & 0 deletions Doc/library/shelve.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ Restrictions
differs across Unix versions and requires knowledge about the database
implementation used.

* On macOS :mod:`dbm.ndbm` can silently corrupt the database file on updates,
which can cause hard crashes when trying to read from the database.


.. class:: Shelf(dict, protocol=None, writeback=False, keyencoding='utf-8')

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Document that :mod:`dbm.ndbm` can silently corrupt DBM files on updates when
exceeding undocumented platform limits, and can crash (segmentation fault)
when reading such a corrupted file. (FB8919203)

0 comments on commit 589da93

Please sign in to comment.