-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 account_objects with invalid marker do not return an error #5046
base: develop
Are you sure you want to change the base?
Changes from 2 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 |
---|---|---|
|
@@ -249,8 +249,18 @@ getAccountObjects( | |
if (!dir) | ||
{ | ||
// it's possible the user had nftoken pages but no | ||
// directory entries | ||
return mlimit < limit; | ||
// directory entries. If there's no nftoken page, we will | ||
// give empty array for account_objects. | ||
if (mlimit >= limit) | ||
jvResult[jss::account_objects] = Json::arrayValue; | ||
|
||
yinyiqian1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// non-zero dirIndex validity was checked in the caller function; | ||
// by this point, it should be zero. | ||
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. as commented elsewhere, I would prefer if this function did not rely on the validation 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. updated |
||
// This function returns true regardless of nftoken page presence; | ||
// if absent, account_objects is already set as an empty array. | ||
// Notice we will only return false in this function when entryIndex | ||
// can not be found, indicating an invalid marker error. | ||
return true; | ||
} | ||
|
||
std::uint32_t i = 0; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -283,6 +283,10 @@ doAccountObjects(RPC::JsonContext& context) | |
return RPC::invalid_field_error(jss::marker); | ||
} | ||
|
||
// check if dirIndex is valid | ||
if (!dirIndex.isZero() && !ledger->read({ltDIR_NODE, dirIndex})) | ||
return RPC::invalid_field_error(jss::marker); | ||
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. since 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. updated |
||
|
||
if (!RPC::getAccountObjects( | ||
*ledger, | ||
accountID, | ||
|
@@ -291,9 +295,7 @@ doAccountObjects(RPC::JsonContext& context) | |
entryIndex, | ||
limit, | ||
result)) | ||
{ | ||
result[jss::account_objects] = Json::arrayValue; | ||
} | ||
return RPC::invalid_field_error(jss::marker); | ||
|
||
result[jss::account] = toBase58(accountID); | ||
context.loadType = Resource::feeMediumBurdenRPC; | ||
|
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.
please also add here check that this is the last page:
BEAST_EXPECT(!resp[jss::result].isMember(jss::marker));
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.
added