@@ -52,7 +52,7 @@ function ConnectPacket(connectData, sAtts, flags = 0) {
5252 }
5353
5454 /* Building Connect Packet */
55- this . buf = Buffer . alloc ( size ) ;
55+ this . buf = Buffer . allocUnsafe ( size ) . fill ( 0 ) ;
5656 this . buf . writeUInt16BE ( size , constants . NSPHDLEN ) ;
5757 this . buf . writeUInt8 ( flags , constants . NSPHDFLGS ) ;
5858 this . buf . writeUInt8 ( constants . NSPTCN , constants . NSPHDTYP ) ;
@@ -156,7 +156,7 @@ function DataPacket(isLargeSDU) {
156156 /* Building Data Packet */
157157 this . dataPtr = constants . NSPDADAT ;
158158 this . dataLen = constants . NSPDADAT ;
159- this . buf = Buffer . alloc ( len ) ;
159+ this . buf = Buffer . allocUnsafe ( len ) . fill ( 0 ) ;
160160 this . buf . writeUInt8 ( 0 , constants . NSPHDFLGS ) ;
161161 this . buf . writeUInt8 ( constants . NSPTDA , constants . NSPHDTYP ) ;
162162 this . bufLen = len ; /* Length of buffer */
@@ -377,7 +377,7 @@ function ControlPacket() {
377377 } else if ( err1 == NSESENDMESG ) {
378378 this . errno = err1 ;
379379 this . notifLen = err2 ;
380- this . notif = Buffer . alloc ( err2 + 1 ) ;
380+ this . notif = Buffer . allocUnsafe ( err2 + 1 ) . fill ( 0 ) ;
381381 this . buf . copy ( this . notif , 0 , constants . NSPCTLDAT + 12 , constants . NSPCTLDAT + 12 + err2 ) ;
382382 } else {
383383 this . errno = err1 ;
0 commit comments