Skip to content

Fix "invalid lib version" crash #7920

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

Merged
merged 4 commits into from
Aug 28, 2018

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Aug 24, 2018

Fix #7917

The actual fix is 6e030b8, BTW I've added some more commits to clean up things out.


UserLibrary res = new UserLibrary();
res.installedFolder = libFolder;
res.name = properties.get("name").trim();
res.version = version.toString();
res.version = version.isPresent() ? version.get().toString() : declaredVersion;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could using "declaredVersion" have unintended consequences? As I understand this, it would allow libraries to put any arbitrary string into Arduino's data structures. Is everything else in the Arduino code able to handle any arbitrary text, when it's all been designed around the until-now strictly enforced major.minor.patch format?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version field for user libraries has always been a String and the format has never been forced to be semver compliant.

To compare version "strings" we use the VersionComparator class that compares two different version "strings", say A and B, using the following alogrithm:

  1. parse A and B as semver
  2. if both A and B are valid semver, compare them using semver rules
  3. if A is valid semver but not B, then A is the greatest
  4. if B is valid semver but not A, then B is the greatest
  5. if both A and B are not valid semver, consider them equals

This logic allows libraires that are not semver compliant to soft transition to semver (since a valid semver version is always greater).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, sounds like you've thought this through quite carefully. I was thinking simpler less-is-more in #7922, after having a user reports 1.8.6 unable to start up.

@per1234
Copy link
Collaborator

per1234 commented Aug 25, 2018

Fixes #3215
👍

@facchinm facchinm added this to the Release 1.8.7 milestone Aug 27, 2018
@cmaglie cmaglie merged commit d2a251c into arduino:master Aug 28, 2018
@cmaglie cmaglie deleted the fix-invalid-lib-version-crash branch August 28, 2018 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IDE won't start after installing a library with an invalid version
5 participants