Project

General

Profile

Bug #4368

Undefined behavior in Block operator==

Added by Davide Pesavento over 3 years ago. Updated over 3 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
[...]
#1

Updated by Davide Pesavento over 3 years ago

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

Updated by Davide Pesavento over 3 years ago

  • Status changed from Code review to Closed

Also available in: Atom PDF