@@ -8,13 +8,11 @@ function FieldPacket(options) {
8
8
this . orgTable = options . orgTable ;
9
9
this . name = options . name ;
10
10
this . orgName = options . orgName ;
11
- this . filler1 = undefined ;
12
11
this . charsetNr = options . charsetNr ;
13
12
this . length = options . length ;
14
13
this . type = options . type ;
15
14
this . flags = options . flags ;
16
15
this . decimals = options . decimals ;
17
- this . filler2 = undefined ;
18
16
this . default = options . default ;
19
17
this . zeroFill = options . zeroFill ;
20
18
this . protocol41 = options . protocol41
@@ -28,13 +26,21 @@ FieldPacket.prototype.parse = function(parser) {
28
26
this . orgTable = parser . parseLengthCodedString ( ) ;
29
27
this . name = parser . parseLengthCodedString ( ) ;
30
28
this . orgName = parser . parseLengthCodedString ( ) ;
31
- this . filler1 = parser . parseFiller ( 1 ) ;
29
+
30
+ if ( parser . parseLengthCodedNumber ( ) !== 0x0c ) {
31
+ throw new TypeError ( 'Received invalid field length' ) ;
32
+ }
33
+
32
34
this . charsetNr = parser . parseUnsignedNumber ( 2 ) ;
33
35
this . length = parser . parseUnsignedNumber ( 4 ) ;
34
36
this . type = parser . parseUnsignedNumber ( 1 ) ;
35
37
this . flags = parser . parseUnsignedNumber ( 2 ) ;
36
38
this . decimals = parser . parseUnsignedNumber ( 1 ) ;
37
- this . filler2 = parser . parseFiller ( 2 ) ;
39
+
40
+ var filler = parser . parseBuffer ( 2 ) ;
41
+ if ( filler [ 0 ] !== 0x0 || filler [ 1 ] !== 0x0 ) {
42
+ throw new TypeError ( 'Received invalid filler' ) ;
43
+ }
38
44
39
45
// parsed flags
40
46
this . zeroFill = ( this . flags & 0x0040 ? true : false ) ;
@@ -43,7 +49,7 @@ FieldPacket.prototype.parse = function(parser) {
43
49
return ;
44
50
}
45
51
46
- this . default = parser . parseLengthCodedNumber ( ) ;
52
+ this . default = parser . parseLengthCodedString ( ) ;
47
53
} else {
48
54
this . table = parser . parseLengthCodedString ( ) ;
49
55
this . name = parser . parseLengthCodedString ( ) ;
@@ -60,7 +66,8 @@ FieldPacket.prototype.write = function(writer) {
60
66
writer . writeLengthCodedString ( this . orgTable ) ;
61
67
writer . writeLengthCodedString ( this . name ) ;
62
68
writer . writeLengthCodedString ( this . orgName ) ;
63
- writer . writeFiller ( 1 ) ;
69
+
70
+ writer . writeLengthCodedNumber ( 0x0c ) ;
64
71
writer . writeUnsignedNumber ( 2 , this . charsetNr || 0 ) ;
65
72
writer . writeUnsignedNumber ( 4 , this . length || 0 ) ;
66
73
writer . writeUnsignedNumber ( 1 , this . type || 0 ) ;
0 commit comments