Describe the bug
When I send http request using curl with invalid json where I put value without double quotes, even if json processing is inside try-catch block, my application fails.
To Reproduce
Filter starting with next code:
try {
auto json = *req->getJsonObject();
// here could be next code processing json data
} catch (...) {
std::cerr << "Invalid JSON" << std::endl;
}
HttpController using this filter for some endpoint,
Curl request to the corresponding endpoint:
curl -s -H "Content-Type: application/json" -X POST --data '{"name": value}' http://localhost:5432/someApi --trace-ascii -
(--trace-ascii is to see request body in curl)
Result:
20240604 13:24:57.709201 UTC 37773 DEBUG [parseJson] * Line 1, Column 10
Syntax error: value, object or array expected.
- HttpRequestImpl.cc:57
Segmentation fault (core dumped)
Expected behavior
I really expected the execution to continue inside catch without segfaulting the whole application.
Desktop (please complete the following information):
OS: Arch Linux
Browser: curl
Version: 8.8.0
Additional context
I found it accidentally when wrote some API test using curl, and started playing with environment variables substitution.
Describe the bug When I send http request using curl with invalid json where I put value without double quotes, even if json processing is inside try-catch block, my application fails.
To Reproduce
Filter starting with next code:
HttpController using this filter for some endpoint,
Curl request to the corresponding endpoint:
curl -s -H "Content-Type: application/json" -X POST --data '{"name": value}' http://localhost:5432/someApi --trace-ascii -
(--trace-ascii
is to see request body in curl)Result:
Expected behavior I really expected the execution to continue inside catch without segfaulting the whole application.
Desktop (please complete the following information):
Additional context I found it accidentally when wrote some API test using curl, and started playing with environment variables substitution.