@@ -52,7 +52,7 @@ function ConnectPacket(connectData, sAtts, flags = 0) {
52
52
}
53
53
54
54
/* Building Connect Packet */
55
- this . buf = Buffer . alloc ( size ) ;
55
+ this . buf = Buffer . allocUnsafe ( size ) . fill ( 0 ) ;
56
56
this . buf . writeUInt16BE ( size , constants . NSPHDLEN ) ;
57
57
this . buf . writeUInt8 ( flags , constants . NSPHDFLGS ) ;
58
58
this . buf . writeUInt8 ( constants . NSPTCN , constants . NSPHDTYP ) ;
@@ -156,7 +156,7 @@ function DataPacket(isLargeSDU) {
156
156
/* Building Data Packet */
157
157
this . dataPtr = constants . NSPDADAT ;
158
158
this . dataLen = constants . NSPDADAT ;
159
- this . buf = Buffer . alloc ( len ) ;
159
+ this . buf = Buffer . allocUnsafe ( len ) . fill ( 0 ) ;
160
160
this . buf . writeUInt8 ( 0 , constants . NSPHDFLGS ) ;
161
161
this . buf . writeUInt8 ( constants . NSPTDA , constants . NSPHDTYP ) ;
162
162
this . bufLen = len ; /* Length of buffer */
@@ -377,7 +377,7 @@ function ControlPacket() {
377
377
} else if ( err1 == NSESENDMESG ) {
378
378
this . errno = err1 ;
379
379
this . notifLen = err2 ;
380
- this . notif = Buffer . alloc ( err2 + 1 ) ;
380
+ this . notif = Buffer . allocUnsafe ( err2 + 1 ) . fill ( 0 ) ;
381
381
this . buf . copy ( this . notif , 0 , constants . NSPCTLDAT + 12 , constants . NSPCTLDAT + 12 + err2 ) ;
382
382
} else {
383
383
this . errno = err1 ;
0 commit comments