mysql2 3.19.0 → 3.19.1-canary.7c2ae002
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/lib/packets/packet.js +29 -6
- package/package.json +4 -4
package/lib/packets/packet.js
CHANGED
|
@@ -516,16 +516,20 @@ class Packet {
|
|
|
516
516
|
return result * sign;
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
-
//
|
|
519
|
+
// adapted from https://github.com/mysqljs/mysql/blob/dc9c152a87ec51a1f647447268917243d2eab1fd/lib/protocol/Parser.js
|
|
520
520
|
parseGeometryValue() {
|
|
521
521
|
const buffer = this.readLengthCodedBuffer();
|
|
522
522
|
let offset = 4;
|
|
523
523
|
if (buffer === null || !buffer.length) {
|
|
524
524
|
return null;
|
|
525
525
|
}
|
|
526
|
+
const bufferLength = buffer.length;
|
|
526
527
|
function parseGeometry() {
|
|
527
|
-
let x, y, i, j, numPoints, line;
|
|
528
|
+
let x, y, i, j, numPoints, numRings, num, line;
|
|
528
529
|
let result = null;
|
|
530
|
+
if (offset + 5 > bufferLength) {
|
|
531
|
+
return null;
|
|
532
|
+
}
|
|
529
533
|
const byteOrder = buffer.readUInt8(offset);
|
|
530
534
|
offset += 1;
|
|
531
535
|
const wkbType = byteOrder
|
|
@@ -534,6 +538,9 @@ class Packet {
|
|
|
534
538
|
offset += 4;
|
|
535
539
|
switch (wkbType) {
|
|
536
540
|
case 1: // WKBPoint
|
|
541
|
+
if (offset + 16 > bufferLength) {
|
|
542
|
+
return null;
|
|
543
|
+
}
|
|
537
544
|
x = byteOrder
|
|
538
545
|
? buffer.readDoubleLE(offset)
|
|
539
546
|
: buffer.readDoubleBE(offset);
|
|
@@ -545,12 +552,18 @@ class Packet {
|
|
|
545
552
|
result = { x: x, y: y };
|
|
546
553
|
break;
|
|
547
554
|
case 2: // WKBLineString
|
|
555
|
+
if (offset + 4 > bufferLength) {
|
|
556
|
+
return null;
|
|
557
|
+
}
|
|
548
558
|
numPoints = byteOrder
|
|
549
559
|
? buffer.readUInt32LE(offset)
|
|
550
560
|
: buffer.readUInt32BE(offset);
|
|
551
561
|
offset += 4;
|
|
552
562
|
result = [];
|
|
553
563
|
for (i = numPoints; i > 0; i--) {
|
|
564
|
+
if (offset + 16 > bufferLength) {
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
554
567
|
x = byteOrder
|
|
555
568
|
? buffer.readDoubleLE(offset)
|
|
556
569
|
: buffer.readDoubleBE(offset);
|
|
@@ -563,19 +576,27 @@ class Packet {
|
|
|
563
576
|
}
|
|
564
577
|
break;
|
|
565
578
|
case 3: // WKBPolygon
|
|
566
|
-
|
|
567
|
-
|
|
579
|
+
if (offset + 4 > bufferLength) {
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
numRings = byteOrder
|
|
568
583
|
? buffer.readUInt32LE(offset)
|
|
569
584
|
: buffer.readUInt32BE(offset);
|
|
570
585
|
offset += 4;
|
|
571
586
|
result = [];
|
|
572
587
|
for (i = numRings; i > 0; i--) {
|
|
588
|
+
if (offset + 4 > bufferLength) {
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
573
591
|
numPoints = byteOrder
|
|
574
592
|
? buffer.readUInt32LE(offset)
|
|
575
593
|
: buffer.readUInt32BE(offset);
|
|
576
594
|
offset += 4;
|
|
577
595
|
line = [];
|
|
578
596
|
for (j = numPoints; j > 0; j--) {
|
|
597
|
+
if (offset + 16 > bufferLength) {
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
579
600
|
x = byteOrder
|
|
580
601
|
? buffer.readDoubleLE(offset)
|
|
581
602
|
: buffer.readDoubleBE(offset);
|
|
@@ -593,8 +614,10 @@ class Packet {
|
|
|
593
614
|
case 5: // WKBMultiLineString
|
|
594
615
|
case 6: // WKBMultiPolygon
|
|
595
616
|
case 7: // WKBGeometryCollection
|
|
596
|
-
|
|
597
|
-
|
|
617
|
+
if (offset + 4 > bufferLength) {
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
num = byteOrder
|
|
598
621
|
? buffer.readUInt32LE(offset)
|
|
599
622
|
: buffer.readUInt32BE(offset);
|
|
600
623
|
offset += 4;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mysql2",
|
|
3
|
-
"version": "3.19.
|
|
3
|
+
"version": "3.19.1-canary.7c2ae002",
|
|
4
4
|
"description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "typings/mysql/index",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"test:bun:parallel": "bun poku -c=\"poku.config.mjs\" test",
|
|
16
16
|
"test:bun:global": "cross-env SUITE=global bun poku -c=\"poku.config.mjs\" test/global",
|
|
17
17
|
"test:deno": "npm run test:deno:parallel && npm run test:deno:global",
|
|
18
|
-
"test:deno:parallel": "deno run --allow-read --allow-env --allow-run npm:poku
|
|
19
|
-
"test:deno:global": "cross-env SUITE=global deno run --allow-read --allow-env --allow-run npm:poku
|
|
18
|
+
"test:deno:parallel": "deno run --allow-read --allow-env --allow-run npm:poku -c=\"poku.config.mjs\" test",
|
|
19
|
+
"test:deno:global": "cross-env SUITE=global deno run --allow-read --allow-env --allow-run npm:poku -c=\"poku.config.mjs\" test/global",
|
|
20
20
|
"test:docker:up": "docker compose -f test/docker-compose.yml up --abort-on-container-exit --remove-orphans",
|
|
21
21
|
"test:docker:down": "docker compose -f test/docker-compose.yml down",
|
|
22
22
|
"test:docker:node": "npm run test:docker:up -- node && npm run test:docker:down",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"eslint-plugin-async-await": "^0.0.0",
|
|
88
88
|
"eslint-plugin-prettier": "^5.5.5",
|
|
89
89
|
"globals": "^17.3.0",
|
|
90
|
-
"poku": "^
|
|
90
|
+
"poku": "^4.0.0",
|
|
91
91
|
"portfinder": "^1.0.38",
|
|
92
92
|
"prettier": "^3.8.1",
|
|
93
93
|
"tsx": "^4.21.0",
|