Refuse a PDU whose optional parameters do not end on command_length (#87)

* Regression tests for a truncated TLV tail refused rather than accepted

* Refuse a PDU whose optional parameters do not end on command_length

* Assert the bare TLV header refusal against jsmpp instead of recording it as a defect

* Note the truncated TLV tail defect as fixed in the java-client findings

* Derive the padding position, share the bare TLV fixture and trim the decision record

* Regression tests for a PDU whose trailing C-Octet String a peer left out

* An absent trailing C-Octet String consumes no octet, so a bodyless PDU still parses

* Bound the TLV loop by the buffer it was given rather than a second spelling of its length

* Answer the stability review's questions in the record and pin the array contract
This commit is contained in:
2026-09-06 18:01:35 +02:00
committed by GitHub
parent c89005168d
commit 039951e69b
11 changed files with 215 additions and 85 deletions
+19 -1
View File
@@ -19,7 +19,7 @@ import { PduRefusedError } from '../src/pdu-refusal.ts';
import { isCommand, objToPdu, pduReturn, pduToObj } from '../src/pdu.ts';
import { paramText } from '../src/defs/types.ts';
import { server } from '../src/server.ts';
import { pduBytes, shortened, truncatedTlv, withUnknownCmdId } from './raw-pdus.ts';
import { bareTlvHeader, pduBytes, shortened, truncatedTlv, withUnknownCmdId } from './raw-pdus.ts';
import { silentLog } from '../src/log.ts';
import { splitMessage } from '../src/message.ts';
@@ -1568,6 +1568,24 @@ describe('a PDU the codec cannot read', () => {
assert.equal((await answerTo(peer)).cmdName, 'enquire_link_resp');
});
test('answers a deliver_sm ending in a bare TLV header with ESME_RINVTLVSTREAM', async t => {
const { peer, session } = await bound(t);
let reports = 0;
session.on('dlr', () => { reports++; });
peer.writeRaw(bareTlvHeader({ cmdName: 'deliver_sm', params: receipt, seqNr: 55 }));
const answered = await answerTo(peer);
assert.equal(answered.cmdName, 'deliver_sm_resp');
assert.equal(answered.cmdStatus, 'ESME_RINVTLVSTREAM');
assert.equal(answered.seqNr, 55);
assert.equal(reports, 0, 'a PDU whose optional parameters were never read is no report');
peer.writeRaw(pduBytes({ cmdName: 'enquire_link', seqNr: 79 }));
assert.equal((await answerTo(peer)).cmdName, 'enquire_link_resp');
});
test('answers a deliver_sm whose body is shorter than it declares with ESME_RINVCMDLEN', async t => {
const { peer } = await bound(t);