Project

General

Profile

Actions

Bug #4368

closed

Undefined behavior in Block operator==

Added by Davide Pesavento about 7 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Category:
Base
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:

Description

If both lhs and rhs have zero length, operator== passes nullptr to memcmp(), which is undefined behavior.

Found by UBSan:

../tests/unit-tests/data.t.cpp(40): Entering test suite "TestData"
../tests/unit-tests/data.t.cpp(259): Entering test case "Equality"
../src/encoding/block.cpp:507:18: runtime error: null pointer passed as argument 1, which is declared to never be null
../src/encoding/block.cpp:507:18: runtime error: null pointer passed as argument 2, which is declared to never be null
../tests/unit-tests/data.t.cpp(265): info: check a == b == true has passed
[...]
Actions

Also available in: Atom PDF