Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CFE-4244: Fix RlistEqual comparison on lists of different lengths (3.18.x) #5321

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

larsewi
Copy link
Contributor

@larsewi larsewi commented Sep 13, 2023

The original issue that leads to this is the fact that the cache
for execresult and execresult_as_data were mixed. This is caused by two
separate issues:

  • The function cache uses the args list as key and discards the function
    itself. This means different function with the same args are considered
    identical, and cache is reused.
  • The args are passed as an Rlist, and the used Rlist comparison ignores the
    additional items of the longest list when comparing two lists of
    different lengths, leading to treating execresult and execresult_as_data
    as identical when using the same command and shell args.

This PR only fixes the specific case of execresult, but leaves other
function cache issues (e.g. host2ip vs. ip2host could be confused).

(cherry picked from commit d5a7372)
Signed-off-by: Lars Erik Wik lars.erik.wik@northern.tech

The original issue that leads to this is the fact that the cache
for execresult and execresult_as_data were mixed. This is caused by two
separate issues:

* The function cache uses the args list as key and discards the function
  itself. This means different function with the same args are considered
  identical, and cache is reused.
* The args are passed as an Rlist, and the used Rlist comparison ignores the
  additional items of the longest list when comparing two lists of
  different lengths, leading to treating execresult and execresult_as_data
  as identical when using the same command and shell args.

This PR only fixes the specific case of execresult, but leaves other
function cache issues (e.g. host2ip vs. ip2host could be confused).

(cherry picked from commit d5a7372)
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
@larsewi
Copy link
Contributor Author

larsewi commented Sep 13, 2023

@cf-bottom Jenkins please :)

@cf-bottom
Copy link

@larsewi
Copy link
Contributor Author

larsewi commented Sep 13, 2023

Cherry picked from #5313

@larsewi larsewi merged commit c25c105 into cfengine:3.18.x Sep 14, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants