Module: kamailio Branch: 6.0 Commit: ee02200c2f4d8820fc9e165925ee25acbb1e3447 URL: https://github.com/kamailio/kamailio/commit/ee02200c2f4d8820fc9e165925ee25acbb1e3447
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2026-02-20T07:30:20+01:00 core: tcp read - checks for MSRP first line (cherry picked from commit 045bf283c095d72e69986403c5835afeca9af4f1) (cherry picked from commit a64fd75c148ab1e224587da9b60ed048366d208a) --- Modified: src/core/tcp_read.c --- Diff: https://github.com/kamailio/kamailio/commit/ee02200c2f4d8820fc9e165925ee25acbb1e3447.diff Patch: https://github.com/kamailio/kamailio/commit/ee02200c2f4d8820fc9e165925ee25acbb1e3447.patch --- diff --git a/src/core/tcp_read.c b/src/core/tcp_read.c index 2cf24246be7..fed840d1c60 100644 --- a/src/core/tcp_read.c +++ b/src/core/tcp_read.c @@ -1042,11 +1042,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!
