<!-- Kamailio Pull Request Template -->
<!-- IMPORTANT: - for detailed contributing guidelines, read: https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md - pull requests must be done to master branch, unless they are backports of fixes from master branch to a stable branch - backports to stable branches must be done with 'git cherry-pick -x ...' - code is contributed under BSD for core and main components (tm, sl, auth, tls) - code is contributed GPLv2 or a compatible license for the other components - GPL code is contributed with OpenSSL licensing exception -->
#### Pre-Submission Checklist <!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply --> <!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above--> <!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list --> - [X] Commit message has the format required by CONTRIBUTING guide - [X Commits are split per component (core, individual modules, libs, utils, ...) - [X] Each component has a single commit (if not, squash them into one commit) - [X] No commits to README files for modules (changes must be done to docbook files in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change - [ ] Small bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds new functionality) - [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist: <!-- Go over all points below, and after creating the PR, tick the checkboxes that apply --> - [ ] PR should be backported to stable branches - [X] Tested changes locally - [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description <!-- Describe your changes in detail -->
Enable the parsing of broken SIP messages.
@lbalaceanu is the original developer of this patch. You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/2245
-- Commit Summary --
* sipcapture: add new capture_bad_msgs modparam
-- File Changes --
M src/modules/sipcapture/doc/sipcapture_admin.xml (18) M src/modules/sipcapture/sipcapture.c (182)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/2245.patch https://github.com/kamailio/kamailio/pull/2245.diff
henningw commented on this pull request.
Thanks for the pull request, I did a quick review and found a few minor things that should be adressed before merging.
@@ -434,6 +436,64 @@ struct module_exports exports = {
destroy /* module destroy function */ };
+/* + * Find the first occurrence of find in s, where the search is limited to the + * first slen characters of s. + */ +char *strnstr(const char *s, const char *find, size_t slen)
Please try to use the existing implementation: src/core/str.h 130:char* _strnstr(const char *s, const char *find, size_t slen);
} else {
- if(cb->star) { /* in the case Contact is "*" */ - memset(&contact, 0, sizeof(contact)); - contact.user.s = star_contact.s; - contact.user.len = star_contact.len; + LM_DBG("error while parsing Contact: header\n"); + } + } else { + cb = (contact_body_t*)msg->contact->parsed; + if (cb) { + if (cb->contacts) { + if (parse_uri(cb->contacts->uri.s, cb->contacts->uri.len, &contact) < 0) { + if (!parse_bad_msgs) { + LOG(L_ERR, "ERROR: do_action: bad contact dropping"" packet\n");
not needed "" probably from line wrapping
+{
+ char *tmp = NULL; + char *end; + struct hdr_field *hdr = NULL; + + tmp= msg->unparsed; + end = msg->buf+msg->len; + tmp = strnstr(tmp, "Call-ID", (int)(end - tmp) ); + + if (tmp == NULL) { + LM_DBG("Bad msg callid not found\n"); + EMPTY_STR(sco->callid); + } else { + hdr=pkg_malloc(sizeof(struct hdr_field)); + if (unlikely(hdr==0)){ + LOG(L_ERR, "ERROR:parse_headers: memory allocation error\n");
consider removing this log statement and just use PKG_MEM_ERROR macro instead. The "parse_headers" prefix makes also not much sense in this context, I think.
@smititelu pushed 1 commit.
5a94bd4606a7a7ae727145cc3faaadac0fbf84f7 sipcapture: add new capture_bad_msgs modparam
updated the commit accoding to the above comments.
Thanks you. Lets wait a bit if there are other comments from developers, otherwise it probably can be merged by the end of the week.
Merged #2245 into master.