Source: libjsoncpp Version: 0.6.0~rc2-3 Severity: normal Tag: patch Hello,
libjsoncpp raises an exception when asked to convert a numerical value
to string. According to the investigation of Matthew Bekkema, this is
what causes the bug #733974 against the package minetest: my upstream
fixed their version of libjsoncpp, but the bug still occures in the
debian package, so debian clients are segfaulting when communicating
with non-debian servers. Could you please consider integrating the
attached patch (authored by Matthew)? I could NMU your package to get
that bug fixed, if you prefer.
Here is a simple valid program that is misbehaving:
------------------------------>8----
#include <iostream>
#include <json/json.h>
const std::string test_data = "{\"test\": 9001}";
int main() {
Json::Value root;
Json::Reader reader;
reader.parse(test_data,root);
if (root["test"].isConvertibleTo(Json::stringValue)) {
std::cout << root["test"].asString() << std::endl;
}
return 0;
}
-----8<-----------------------------
Instead of displaying a simple "9001", it shows:
| terminate called after throwing an instance of 'std::runtime_error'
| what(): Type is not convertible to string
The fix to that bug is a one-liner. As you can see, the patch also
fixes two other errors in the source, where null values where marked
as convertible to arrays and to objects. This is obviously wrong, as
trying to convert null to these types raises the segfaults that we are
observing in minetest.
Thanks for your work,
Mt.
-- System Information:
Debian Release: jessie/sid
APT prefers testing-updates
APT policy: (500, 'testing-updates'), (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.14-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
--
I don't care whichever programming language we choose, as long as it's C.
--- a/json_value.cpp
+++ b/json_value.cpp
@@ -666,6 +666,7 @@ Value::asString() const
case booleanValue:
return value_.bool_ ? "true" : "false";
case intValue:
+ return valueToString( value_.int_ );
case uintValue:
case realValue:
case arrayValue:
@@ -1423,14 +1424,14 @@ Value::isString() const
bool
Value::isArray() const
{
- return type_ == nullValue || type_ == arrayValue;
+ return type_ == arrayValue;
}
bool
Value::isObject() const
{
- return type_ == nullValue || type_ == objectValue;
+ return type_ == objectValue;
}
signature.asc
Description: Digital signature

