[sr-dev] [kamailio/kamailio] sipcapture: add new capture_bad_msgs modparam (#2245)

Henning Westerholt notifications at github.com
Wed Mar 11 11:17:28 CET 2020


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. 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/2245#pullrequestreview-372615285
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20200311/d09f1fec/attachment-0001.html>


More information about the sr-dev mailing list