cbor-extract 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/src/extract.cpp +6 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cbor-extract",
|
|
3
3
|
"author": "Kris Zyp",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.2",
|
|
5
5
|
"description": "Node addon for string extraction for cbor-x",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"prebuildify-cross": "5.0.0"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
|
-
"@cbor-extract/cbor-extract-darwin-arm64": "2.2.
|
|
44
|
-
"@cbor-extract/cbor-extract-darwin-x64": "2.2.
|
|
45
|
-
"@cbor-extract/cbor-extract-linux-arm": "2.2.
|
|
46
|
-
"@cbor-extract/cbor-extract-linux-arm64": "2.2.
|
|
47
|
-
"@cbor-extract/cbor-extract-linux-x64": "2.2.
|
|
48
|
-
"@cbor-extract/cbor-extract-win32-x64": "2.2.
|
|
43
|
+
"@cbor-extract/cbor-extract-darwin-arm64": "2.2.2",
|
|
44
|
+
"@cbor-extract/cbor-extract-darwin-x64": "2.2.2",
|
|
45
|
+
"@cbor-extract/cbor-extract-linux-arm": "2.2.2",
|
|
46
|
+
"@cbor-extract/cbor-extract-linux-arm64": "2.2.2",
|
|
47
|
+
"@cbor-extract/cbor-extract-linux-x64": "2.2.2",
|
|
48
|
+
"@cbor-extract/cbor-extract-win32-x64": "2.2.2"
|
|
49
49
|
}
|
|
50
50
|
}
|
package/src/extract.cpp
CHANGED
|
@@ -84,7 +84,7 @@ public:
|
|
|
84
84
|
lastStringEnd = 0;
|
|
85
85
|
position = startingPosition;
|
|
86
86
|
source = inputSource;
|
|
87
|
-
if (startingPosition + firstStringSize > size) {
|
|
87
|
+
if ((uint64_t)startingPosition + firstStringSize > size) {
|
|
88
88
|
return unexpectedEnd(env);
|
|
89
89
|
}
|
|
90
90
|
readString(env, firstStringSize, firstStringSize < 0x100);
|
|
@@ -124,11 +124,11 @@ public:
|
|
|
124
124
|
}
|
|
125
125
|
if (majorType == 3) {
|
|
126
126
|
// string
|
|
127
|
-
if (length + position > size) {
|
|
127
|
+
if ((uint64_t)length + position > size) {
|
|
128
128
|
return unexpectedEnd(env);
|
|
129
129
|
}
|
|
130
130
|
readString(env, length, length < 0x100);
|
|
131
|
-
if (writePosition >= MAX_TARGET_SIZE)
|
|
131
|
+
if (writePosition >= MAX_TARGET_SIZE - 1) // reserve slot for double-write
|
|
132
132
|
break;
|
|
133
133
|
} else { // binary data
|
|
134
134
|
position += length;
|
|
@@ -194,6 +194,9 @@ napi_value extractStrings(napi_env env, napi_callback_info info) {
|
|
|
194
194
|
napi_throw_type_error(env, NULL, "Unexpected buffer type, expected a Buffer");
|
|
195
195
|
return args[0];
|
|
196
196
|
}
|
|
197
|
+
if (size > buffer_size || position > buffer_size) {
|
|
198
|
+
return unexpectedEnd(env);
|
|
199
|
+
}
|
|
197
200
|
return extractor->extractStrings(env, position, size, firstStringSize, source);
|
|
198
201
|
}
|
|
199
202
|
#define EXPORT_NAPI_FUNCTION(name, func) { napi_property_descriptor desc = { name, 0, func, 0, 0, 0, (napi_property_attributes) (napi_writable | napi_configurable), 0 }; napi_define_properties(env, exports, 1, &desc); }
|