Skip to content

Suspicious comparison at lfs_dir_find_match() #923

Open
@andriyndev

Description

@andriyndev

The function uses lfs_bd_cmp() which, from what I understand, compares data on disk with an arbitrary data passed as argument, and returns:

  • LFS_CMP_LT - the data on disk is less than the arbitrary data
  • LFS_CMP_GT - the data on disk is greater than the arbitrary data
  • LFS_CMP_EQ - the data on disk and the arbitrary data are equal

If the function returns LFS_CMP_EQ, we perform an additional comparison:

    if (name->size != lfs_tag_size(tag)) {
        return (name->size < lfs_tag_size(tag)) ? LFS_CMP_LT : LFS_CMP_GT;
    }

This comparison looks suspicious because it returns LFS_CMP_LT is the arbitrary data (not the data on disk) is shorter than the data on disk. Maybe it was intended this way but just in case decided to report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs fixwe know what is wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions