mirror of
https://github.com/amigan/aim-oscar-server.git
synced 2024-11-21 20:19:47 -05:00
asserts for FLAP, SNAC headers
This commit is contained in:
parent
f762506bf4
commit
f20f524af0
1 changed files with 3 additions and 1 deletions
|
@ -31,6 +31,7 @@ class TLV {
|
||||||
|
|
||||||
class SNAC {
|
class SNAC {
|
||||||
static fromBuffer(buf, payloadLength = 0) {
|
static fromBuffer(buf, payloadLength = 0) {
|
||||||
|
assert(buf.length >= 10, 'Expected 10 bytes for SNAC header');
|
||||||
const family = buf.slice(0,2).readInt16BE(0);
|
const family = buf.slice(0,2).readInt16BE(0);
|
||||||
const service = buf.slice(2,4).readInt16BE(0);
|
const service = buf.slice(2,4).readInt16BE(0);
|
||||||
const flags = buf.slice(4, 6);
|
const flags = buf.slice(4, 6);
|
||||||
|
@ -85,7 +86,8 @@ class SNAC {
|
||||||
|
|
||||||
class FLAP {
|
class FLAP {
|
||||||
static fromBuffer(buf) {
|
static fromBuffer(buf) {
|
||||||
assert.equal(buf[0], 0x2a, 'Expected 0x2a FLAP header');
|
assert.equal(buf[0], 0x2a, 'Expected 0x2a at start of FLAP header');
|
||||||
|
assert(buf.length >= 6, 'Expected at least 6 bytes for FLAP header');
|
||||||
const channel = buf.readInt8(1);
|
const channel = buf.readInt8(1);
|
||||||
const sequenceNumber = buf.slice(2,4).readInt16BE(0);
|
const sequenceNumber = buf.slice(2,4).readInt16BE(0);
|
||||||
const payloadLength = buf.slice(4, 6).readInt16BE(0);
|
const payloadLength = buf.slice(4, 6).readInt16BE(0);
|
||||||
|
|
Loading…
Reference in a new issue