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

Portage version comparison is not working #1459

Closed
tomerse-sg opened this issue Aug 24, 2023 · 2 comments · Fixed by #1468
Closed

Portage version comparison is not working #1459

tomerse-sg opened this issue Aug 24, 2023 · 2 comments · Fixed by #1468
Labels
bug Something isn't working good-first-issue Good for newcomers

Comments

@tomerse-sg
Copy link

What happened:
I think I've found a bug in portage compare function.
the bug happens in this part -

	r1 := big.NewInt(0)
	if match1[9] != "" {
		r1.SetString(match1[9], 10)
	}
	r2 := big.NewInt(0)
	if match2[9] != "" {
		r1.SetString(match2[9], 10)
	}

The r1.SetString(match2[9], 10) in the 2nd time should be r2.SetString(match2[9], 10)

What you expected to happen:
the 1.2.3-r2 should be higher than 1.2.3-r1
How to reproduce it (as minimally and precisely as possible):
run the below code

	res := comparePortageVersions("1.2.3-r1", "1.2.3-r2")
	print(res)

Anything else we need to know?:

Environment:

  • Output of grype version: latest
  • OS (e.g: cat /etc/os-release or similar): macOS
@tomerse-sg tomerse-sg added the bug Something isn't working label Aug 24, 2023
@kzantow
Copy link
Contributor

kzantow commented Aug 24, 2023

@tomerse-sg this looks to be a problem, quite likely exactly as you've described -- are you able to add a PR for this?

@kzantow kzantow added the good-first-issue Good for newcomers label Aug 24, 2023
barnuri added a commit to barnuri/grype that referenced this issue Aug 27, 2023
barnuri added a commit to barnuri/grype that referenced this issue Aug 27, 2023
Signed-off-by: Bar Nuri <[email protected]>
@tomerse-sg
Copy link
Author

@kzantow please see the pr

@wagoodman wagoodman changed the title possible bug in portage compare Portage version comparison is not working Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good-first-issue Good for newcomers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants