bulentv / js_zklib

Attendance Machine Library for NodeJS with a connection to the network using the UDP protocol and port 4370
GNU General Public License v2.0
56 stars 46 forks source link

crash fix for empty attendance data #51

Closed MinhasKamal closed 6 years ago

MinhasKamal commented 6 years ago

Was crashing for empty attendance. Error log:

    buffer.js:977
        throw new RangeError('Index out of range');
        ^
    RangeError: Index out of range
        at checkOffset (buffer.js:977:11)
        at Uint8Array.Buffer.readUInt32LE (buffer.js:1039:5)
        at Socket.handleOnData (P:\WebApp\ZKTecoDataCollector\node_modules\zklib\zklib\zkattendance.js:55:33)
        at emitTwo (events.js:131:20)
        at Socket.emit (events.js:214:7)
        at UDP.onMessage [as onmessage] (dgram.js:659:8)

Fix reference: https://nodejs.org/api/buffer.html#buffer_buf_readuint32le_offset

mribichich commented 6 years ago

thanks @MinhasKamal for finding the bug.

I went with a different approach, checking for the message response instead. I'll be merging in a while

derit commented 4 years ago

i verified this as fixed this bug