Skip to content

"when" statement previously resolved to FALSE and newly resolved to TRUE : segfault #1953

@Haititi

Description

@Haititi

Hi,

I know that libyang1 is deprecated, but as i found this bug and have a fix for it, it is better to share it.
In file https://github.com/CESNET/libyang/blob/libyang1/src/resolve.c#L8631 , i fell in a case where the when statement was previously resolved to false (prev_when_status = LYD_WHEN | LYD_WHEN_FALSE).
Calling resolve_unres_data_item() would call resolve_when() which will now resolve to true (node->when_status |= LYD_WHEN_TRUE), but due to the when_status flag not being reset, we end up with a wrong value:
node->when_status = LYD_WHEN | LYD_WHEN_FALSE | LYD_WHEN_TRUE .

This makes the code crash in file https://github.com/CESNET/libyang/blob/libyang1/src/resolve.c#L8638 because the condition unres->node[i]->when_status & LYD_WHEN_FALSE is still true, but the when pointer is NULL due to the successful resolve.

resetting the flag in resolve_when() by adding node->when_status &= LYD_WHEN; at the beginning of the function would fix the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    is:bugBug description.libyang1Related to libyang 1 supportstatus:completedFrom the developer perspective, the issue was solved (bug fixed, question answered,...)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions