Skip to content

Precondition in memcpy is too strict #3482

Closed
@danielsn

Description

@danielsn

In memcpy there is the following precondition:

 __CPROVER_precondition(__CPROVER_POINTER_OBJECT(dst)!=
                         __CPROVER_POINTER_OBJECT(src),
                         "memcpy src/dst overlap");

However, it is valid to memcpy between two segments of the same allocation, as long as the two segments themselves do not overlap. A better check would be something like

 __CPROVER_precondition(__CPROVER_POINTER_OBJECT(dst)!=
                         __CPROVER_POINTER_OBJECT(src) || (src > dst + n) || ( dst > src + n) ,
                         "memcpy src/dst overlap");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions