Project

General

Profile

Actions

Bug #4368

closed

Undefined behavior in Block operator==

Added by Davide Pesavento about 7 years ago. Updated almost 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 #1

Updated by Davide Pesavento about 7 years ago

  • Status changed from New to Code review
  • % Done changed from 0 to 100
Actions #2

Updated by Davide Pesavento almost 7 years ago

  • Status changed from Code review to Closed
Actions

Also available in: Atom PDF