FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-158063: Fix out-of-bounds read when comparing decimal signal dicts by lazerg · Pull Request #158069 · python/cpython · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .py  (1) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
3 changes: 3 additions & 0 deletions Lib/test/test_decimal.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4026,6 +4026,9 @@ def test_flag_comparisons(self):
self.assertNotEqual(d, c.flags)
self.assertNotEqual(c.flags, d)

self.assertNotEqual(None, c.flags)
self.assertNotEqual(c.flags, None)

@requires_IEEE_754
def test_float_operation(self):
Decimal = self.decimal.Decimal
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix an out-of-bounds read in the C implementation of :mod:`decimal` when
comparing the ``flags`` or ``traps`` of a :class:`~decimal.Context` with an
object that is not a signal dict, such as ``None``.
3 changes: 2 additions & 1 deletion Modules/_decimal/_decimal.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,8 @@ signaldict_richcompare(PyObject *v, PyObject *w, int op)
decimal_state *state = get_module_state_by_def(Py_TYPE(v));
assert(PyDecSignalDict_Check(state, v));

if ((SdFlagAddr(v) == NULL) || (SdFlagAddr(w) == NULL)) {
if ((SdFlagAddr(v) == NULL) ||
(PyDecSignalDict_Check(state, w) && SdFlagAddr(w) == NULL)) {
return value_error_ptr(INVALID_SIGNALDICT_ERROR_MSG);
}

Expand Down
Loading

Back | FazBrowse Home | New Git URL