fix: remove empty bytes from password buffer in StaticAuth #116

This commit is contained in:
simon 2021-05-28 12:36:37 +02:00
parent 5290ac37c0
commit a06026f887

View File

@ -16,7 +16,7 @@ export class UserPasswordPacketHandler implements IPacketHandler {
const username = packet.attributes['User-Name']; const username = packet.attributes['User-Name'];
let password = packet.attributes['User-Password']; let password = packet.attributes['User-Password'];
if (typeof password !== 'string' && password.indexOf(0x00) > 0) { if (Buffer.isBuffer(password) && password.indexOf(0x00) > 0) {
// check if there is a 0x00 in it, and trim it from there // check if there is a 0x00 in it, and trim it from there
password = password.slice(0, password.indexOf(0x00)); password = password.slice(0, password.indexOf(0x00));
} }