Module: kamailio
Branch: master
Commit: 8eb84f76a6d52598bb2fd5d13b96fba4c6326b7f
URL:
https://github.com/kamailio/kamailio/commit/8eb84f76a6d52598bb2fd5d13b96fba…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-07-03T14:58:59+02:00
core: parse rr - reset head in case of parse error
- avoid acessing an invalid pointer
- proper support if trying to parse into an existing rr list in a second
attempt (not the case so far)
---
Modified: src/core/parser/parse_rr.c
---
Diff:
https://github.com/kamailio/kamailio/commit/8eb84f76a6d52598bb2fd5d13b96fba…
Patch:
https://github.com/kamailio/kamailio/commit/8eb84f76a6d52598bb2fd5d13b96fba…
---
diff --git a/src/core/parser/parse_rr.c b/src/core/parser/parse_rr.c
index 4fb32b0265..5740461f6c 100644
--- a/src/core/parser/parse_rr.c
+++ b/src/core/parser/parse_rr.c
@@ -55,6 +55,13 @@ static inline int do_parse_rr_body(char *buf, int len, rr_t **head)
trim_leading(&s);
last = 0;
+ if (*head) {
+ /* go to last rr in list */
+ last = *head;
+ while (last->next) {
+ last = last->next;
+ }
+ }
while(1) {
/* Allocate and clear rr structure */
@@ -128,7 +135,8 @@ static inline int do_parse_rr_body(char *buf, int len, rr_t **head)
error:
if (r) free_rr(&r);
- free_rr(head); /* Free any contacts created so far */
+ free_rr(head); /* Free any rr created so far */
+ *head = NULL;
LM_ERR("Failed parsing rr header body [%.*s]\n", len, ZSW(buf));
return -1;