Module: kamailio
Branch: master
Commit: 368661cc15251af4cbf295d1f5fad5a42d1b647b
URL: 
https://github.com/kamailio/kamailio/commit/368661cc15251af4cbf295d1f5fad5a42d1b647b

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2024-04-05T08:10:11+02:00

core: parser/sdp - function to find sdp line with start EoL check option

---

Modified: src/core/parser/sdp/sdp_helpr_funcs.c
Modified: src/core/parser/sdp/sdp_helpr_funcs.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/368661cc15251af4cbf295d1f5fad5a42d1b647b.diff
Patch: 
https://github.com/kamailio/kamailio/commit/368661cc15251af4cbf295d1f5fad5a42d1b647b.patch

---

diff --git a/src/core/parser/sdp/sdp_helpr_funcs.c 
b/src/core/parser/sdp/sdp_helpr_funcs.c
index d5cb359b40f..a5dffd9c398 100644
--- a/src/core/parser/sdp/sdp_helpr_funcs.c
+++ b/src/core/parser/sdp/sdp_helpr_funcs.c
@@ -733,9 +733,10 @@ int extract_sess_version(str *oline, str *sess_version)
 
 /*
  * Auxiliary for some functions.
+ * - smode: if 1, pstart is pointing inside msg body
  * Returns pointer to first character of found line, or NULL if no such line.
  */
-char *find_sdp_line(char *pstart, char *plimit, char linechar)
+char *find_sdp_line_start(char *pstart, char *plimit, char linechar, int smode)
 {
        static char linehead[3] = "x=";
        char *cp, *cp1;
@@ -749,11 +750,14 @@ char *find_sdp_line(char *pstart, char *plimit, char 
linechar)
                if(cp1 == NULL)
                        return NULL;
                /*
-                * As it is body, we assume it has previous line and we can
-                * lookup previous character.
+                * smode==1 means it is msg body, thus it has previous line and 
it can
+                * lookup previous character even when cp1==pstart.
                 */
-               if(cp1[-1] == '\n' || cp1[-1] == '\r')
-                       return cp1;
+               if(cp1 > pstart || smode == 1) {
+                       if(cp1[-1] == '\n' || cp1[-1] == '\r') {
+                               return cp1;
+                       }
+               }
                /*
                 * Having such data, but not at line beginning.
                 * Skip them and reiterate. ser_memmem() will find next
@@ -765,6 +769,14 @@ char *find_sdp_line(char *pstart, char *plimit, char 
linechar)
        }
 }
 
+/*
+ * Auxiliary for some functions - expect pstart to point inside SIP message 
body.
+ * Returns pointer to first character of found line, or NULL if no such line.
+ */
+char *find_sdp_line(char *pstart, char *plimit, char linechar)
+{
+       return find_sdp_line_start(pstart, plimit, linechar, 1);
+}
 
 /* This function assumes pstart points to a line of requested type. */
 char *find_next_sdp_line(
diff --git a/src/core/parser/sdp/sdp_helpr_funcs.h 
b/src/core/parser/sdp/sdp_helpr_funcs.h
index e8ce6f7e60a..20d3ebd882d 100644
--- a/src/core/parser/sdp/sdp_helpr_funcs.h
+++ b/src/core/parser/sdp/sdp_helpr_funcs.h
@@ -65,6 +65,7 @@ int extract_accept_wrapped_types(str *body, str 
*accept_wrapped_types);
 int extract_max_size(str *body, str *max_size);
 int extract_path(str *body, str *path);
 
+char *find_sdp_line_start(char *pstart, char *plimit, char linechar, int 
smode);
 char *find_sdp_line(char *p, char *plimit, char linechar);
 char *find_next_sdp_line(char *p, char *plimit, char linechar, char *defptr);
 

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to [email protected]

Reply via email to