rippled
rippled copied to clipboard
Submitting JSON values greater than 2*32 returns 400 error
Issue Description
Submitting an integer to rippled greater than 2**32 results in an HTTP response of 400 with the message
Unable to parse request: * Line 1, Column 188\n '4294967296' exceeds the allowable range.
Steps to Reproduce
Submit any request to rippled that contains a number greater than 2**32. Submitting a payment transaction with 4295 XRP or greater will reproduce.
Submitting the value as a string works as expected.
Expected Result
I don't think I've seen another error response from rippled that isn't a 200 HTTP response but if there was an issue an error message is returned.
Actual Result
Since the number isn't getting past the JSON parsing code of rippled I'm not sure how
There is code in json_reader.cpp catching this value:
https://github.com/XRPLF/rippled/blob/c915984340e999cf8224e7d9377eeee8acbc0f2e/src/ripple/json/impl/json_reader.cpp#L606-L612
Are you saying that this situation should return a 200 but include an error message in the response body?
Is it actually valid to submit a payment transaction and provide a number for the amount? (I thought you must submit the value as a string.)
Aren't amounts specified as strings?
For additional color, a WS request with such a value times out and doesn't cleanly error.
This static assert suggests that there's some overflow issues with larger values: https://github.com/XRPLF/rippled/blob/838978b86957534e801859e805f748627af9529c/src/libxrpl/json/json_reader.cpp#L557-L563
FYI Clio doesn't seem to have this issue so perhaps using the same JSON library as them (I think it's mostly just Boost JSON?) would solve this problem.