mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-04-22 05:59:55 +08:00

When parsing numeric values as doubles, its possible for users to specify values that cannot be converted to integers, such as Inf, NaN, and extremes such as 1e100. If this value is received, and then cast to an int, it is undefined behavior, which trips ubsan when running tinygltf under a fuzzer. Instead of parsing integral values as doubles, use nlohmann/json's built-in support to parse integer and unsigned values directly, with .is_number_integer() and .is_number_unsigned(). Add ParseIntegerProperty, ParseUnsignedProperty, and ParseIntegerArrayProperty helpers that allow parsing directly to int/uint values and update code to use them when appropriate.
68 lines
986 B
JSON
68 lines
986 B
JSON
{
|
|
"scenes": [
|
|
{
|
|
"nodes": [0]
|
|
}
|
|
],
|
|
"nodes": [
|
|
{
|
|
"mesh": 0
|
|
}
|
|
],
|
|
"meshes": [
|
|
{
|
|
"primitives": [
|
|
{
|
|
"attributes": {
|
|
"POSITION": 1
|
|
},
|
|
"indices": 0
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"buffers": [
|
|
{
|
|
"uri": "simpleTriangle.bin",
|
|
"byteLength": 44
|
|
}
|
|
],
|
|
"bufferViews": [
|
|
{
|
|
"buffer": 0,
|
|
"byteOffset": 0,
|
|
"byteLength": 1e300,
|
|
"target": 34963
|
|
},
|
|
{
|
|
"buffer": 0,
|
|
"byteOffset": 8,
|
|
"byteLength": 36,
|
|
"target": 34962
|
|
}
|
|
],
|
|
"accessors": [
|
|
{
|
|
"bufferView": 0,
|
|
"byteOffset": 0,
|
|
"componentType": 5123,
|
|
"count": 3,
|
|
"type": "SCALAR",
|
|
"max": [2],
|
|
"min": [0]
|
|
},
|
|
{
|
|
"bufferView": 1,
|
|
"byteOffset": 0,
|
|
"componentType": 5126,
|
|
"count": 3,
|
|
"type": "VEC3",
|
|
"max": [1, 1, 0],
|
|
"min": [0, 0, 0]
|
|
}
|
|
],
|
|
"asset": {
|
|
"version": "2.0"
|
|
}
|
|
}
|