noble / bleno

A Node.js module for implementing BLE (Bluetooth Low Energy) peripherals
MIT License
2.12k stars 448 forks source link

Crash on bonding #345

Open skirge opened 6 years ago

skirge commented 6 years ago

Executed option "Bond" on Bleno device in nRF Connect. Following stacktrace appears

PROJECT/node_modules/bleno/lib/hci-socket/crypto.js:60
  var output = new Buffer(input.length);
                               ^

TypeError: Cannot read property 'length' of undefined
    at swap (PROJECT/node_modules/bleno/lib/hci-socket/crypto.js:60:32)
    at e (PROJECT/node_modules/bleno/lib/hci-socket/crypto.js:37:9)
    at Object.c1 (PROJECT/node_modules/bleno/lib/hci-socket/crypto.js:22:9)
    at Smp.handlePairingRandom (PROJECT/node_modules/bleno/lib/hci-socket/smp.js:130:12)
    at Smp.onAclStreamData (PROJECT/node_modules/bleno/lib/hci-socket/smp.js:58:10)
    at emitTwo (events.js:92:20)
    at emit (events.js:172:7)
    at AclStream.push (PROJECT/node_modules/bleno/lib/hci-socket/acl-stream.js:26:10)
    at BlenoBindings.onAclDataPkt (PROJECT/node_modules/bleno/lib/hci-socket/bindings.js:201:21)
    at emitThree (events.js:97:13)

hcidump.log

bleno 0.4.2 (from git) Distribution: Debian (Kali Linux) bluez 5.47

Linux POLO-1158 4.13.0-kali1-amd64 #1 SMP Debian 4.13.4-2kali1 (2017-10-16) x86_64 GNU/Linux
jackdneilson commented 6 years ago

In smp.js, if handlePairingRandom() is called this._tk is not set leading to the undefined pointer.