mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 15:02:42 +01:00
bugfix in getInteger(const nlohmann::json &) and add bounds checks
improve error messages, too
This commit is contained in:
parent
2ec1303286
commit
788be3f964
5 changed files with 54 additions and 15 deletions
|
|
@ -176,7 +176,7 @@ NarInfo NarInfo::fromJSON(
|
|||
std::nullopt);
|
||||
|
||||
if (json.contains("downloadSize"))
|
||||
res.fileSize = getInteger(valueAt(json, "downloadSize"));
|
||||
res.fileSize = getUnsigned(valueAt(json, "downloadSize"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ UnkeyedValidPathInfo UnkeyedValidPathInfo::fromJSON(
|
|||
|
||||
auto & json = getObject(_json);
|
||||
res.narHash = Hash::parseAny(getString(valueAt(json, "narHash")), std::nullopt);
|
||||
res.narSize = getInteger(valueAt(json, "narSize"));
|
||||
res.narSize = getUnsigned(valueAt(json, "narSize"));
|
||||
|
||||
try {
|
||||
auto references = getStringList(valueAt(json, "references"));
|
||||
|
|
@ -224,7 +224,7 @@ UnkeyedValidPathInfo UnkeyedValidPathInfo::fromJSON(
|
|||
|
||||
if (json.contains("registrationTime"))
|
||||
if (auto * rawRegistrationTime = getNullable(valueAt(json, "registrationTime")))
|
||||
res.registrationTime = getInteger(*rawRegistrationTime);
|
||||
res.registrationTime = getInteger<time_t>(*rawRegistrationTime);
|
||||
|
||||
if (json.contains("ultimate"))
|
||||
res.ultimate = getBoolean(valueAt(json, "ultimate"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue