-
Notifications
You must be signed in to change notification settings - Fork 286
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
Fix crash while parsing malformed manifest files. #1211
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -510,10 +510,15 @@ namespace vcpkg | |||||||||||||||||||||||||||||||||||||||||
return t; | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
static std::string map_illegal_names(std::string&& name) | ||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||
return Json::IdentifierDeserializer::is_ident(name) ? std::move(name) : "<error>"; | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
Optional<DependencyRequestedFeature> visit_string(Json::Reader& r, StringView sv) const override | ||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||
return Json::IdentifierDeserializer::instance.visit_string(r, sv).map( | ||||||||||||||||||||||||||||||||||||||||||
[](std::string&& name) { return std::move(name); }); | ||||||||||||||||||||||||||||||||||||||||||
[](std::string&& name) { return map_illegal_names(std::move(name)); }); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+513
to
522
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should work exactly like
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code would still result in a crash since the constructor of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The point is that things that are deserialized can't have check_exits like that. Notably, the assert doesn't even succeed in maintaining the invariant that it won't be empty, since:
|
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
Optional<DependencyRequestedFeature> visit_object(Json::Reader& r, const Json::Object& obj) const override | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -523,7 +528,7 @@ namespace vcpkg | |||||||||||||||||||||||||||||||||||||||||
r.required_object_field(type_name(), obj, NAME, name, Json::IdentifierDeserializer::instance); | ||||||||||||||||||||||||||||||||||||||||||
r.optional_object_field(obj, PLATFORM, platform, PlatformExprDeserializer::instance); | ||||||||||||||||||||||||||||||||||||||||||
if (name.empty()) return nullopt; | ||||||||||||||||||||||||||||||||||||||||||
return DependencyRequestedFeature{std::move(name), std::move(platform)}; | ||||||||||||||||||||||||||||||||||||||||||
return DependencyRequestedFeature{map_illegal_names(std::move(name)), std::move(platform)}; | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
const static DependencyFeatureDeserializer instance; | ||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI I repeated this in #1219 but #1203 resolves it by making
print_error_message
itself add the extra newline since I found other occurrences.