Module: kamailio Branch: 5.7 Commit: cefd6f97659cb7572ecb32279e1f57d3b68e0f4c URL: https://github.com/kamailio/kamailio/commit/cefd6f97659cb7572ecb32279e1f57d3b68e0f4c
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2026-02-20T10:57:35+01:00 core: tcp read - checks for MSRP first line (cherry picked from commit 045bf283c095d72e69986403c5835afeca9af4f1) (cherry picked from commit a64fd75c148ab1e224587da9b60ed048366d208a) (cherry picked from commit ee02200c2f4d8820fc9e165925ee25acbb1e3447) (cherry picked from commit d542b3372afa4eaa560cf3f99f0f97f30050719f) --- Modified: src/core/tcp_read.c --- Diff: https://github.com/kamailio/kamailio/commit/cefd6f97659cb7572ecb32279e1f57d3b68e0f4c.diff Patch: https://github.com/kamailio/kamailio/commit/cefd6f97659cb7572ecb32279e1f57d3b68e0f4c.patch --- diff --git a/src/core/tcp_read.c b/src/core/tcp_read.c index 015bacd3837..1b9c0a9e0dd 100644 --- a/src/core/tcp_read.c +++ b/src/core/tcp_read.c @@ -1035,11 +1035,31 @@ int tcp_read_headers(struct tcp_connection *c, rd_conn_flags_t *read_flags) /* locate transaction id in first line * -- first line exists, that's why we are here */ mfline = q_memchr(r->start, '\n', r->pos - r->start); - mtransid.s = q_memchr( - r->start + 5 /* 'MSRP ' */, ' ', mfline - r->start); + if(mfline == NULL || mfline - r->start < 8) { + r->error = TCP_READ_ERROR; + r->state = H_SKIP; /* skip now */ + goto skip; + } + mtransid.s = q_memchr(r->start + 5 /* 'MSRP ' */, ' ', + mfline - r->start - 5); + if(mtransid.s == NULL) { + r->error = TCP_READ_ERROR; + r->state = H_SKIP; /* skip now */ + goto skip; + } mtransid.len = mtransid.s - r->start - 5; + if(mtransid.len <= 0) { + r->error = TCP_READ_ERROR; + r->state = H_SKIP; /* skip now */ + goto skip; + } mtransid.s = r->start + 5; trim(&mtransid); + if(mtransid.len <= 0) { + r->error = TCP_READ_ERROR; + r->state = H_SKIP; /* skip now */ + goto skip; + } if(memcmp(mtransid.s, p - 1 /*\r*/ - 1 /* '+'|'#'|'$' */ - mtransid.len, _______________________________________________ Kamailio - Development Mailing List -- [email protected] To unsubscribe send an email to [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender!
