Module: sip-router Branch: master Commit: a3b2fcde99ebd5f625d0168473caef5dbbaf1029 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a3b2fcde...
Author: Jan Janak jan@ryngle.com Committer: Jan Janak jan@ryngle.com Date: Tue Feb 23 14:38:31 2010 -0500
param_parser: Accept parameters with missing bodies.
This change makes the parameter parser more forgiving. It accepts parameters with missing bodies (foo=), such parameters will have the body set to an empty string. Observed on iptel.org
---
parser/parse_param.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/parser/parse_param.c b/parser/parse_param.c index 8dee261..f86d1c9 100644 --- a/parser/parse_param.c +++ b/parser/parse_param.c @@ -455,11 +455,12 @@ inline int parse_param(str *_s, pclass_t _c, param_hooks_t *_h, param_t *t) trim_leading(_s);
if (_s->len == 0) { - LOG(L_ERR, "parse_params(): Body missing\n"); - goto error; - } - - if (parse_param_body(_s, t) < 0) { + /* Be forgiving and accept parameters with missing value, + * we just set the body of such a parameter to an empty + * string. */ + t->body.s = ""; + t->body.len = 0; + } else if (parse_param_body(_s, t) < 0) { LOG(L_ERR, "parse_params(): Error while parsing param body\n"); goto error; }
On 03/02/2010 08:47 PM, Jan Janak wrote:
Module: sip-router Branch: master Commit: a3b2fcde99ebd5f625d0168473caef5dbbaf1029 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a3b2fcde...
Author: Jan Janakjan@ryngle.com Committer: Jan Janakjan@ryngle.com Date: Tue Feb 23 14:38:31 2010 -0500
param_parser: Accept parameters with missing bodies.
This change makes the parameter parser more forgiving. It accepts parameters with missing bodies (foo=), such parameters will have the body set to an empty string. Observed on iptel.org
is this better than setting the pointer after '=' and the len 0?
I haven't checked the code to see if it is the case, the only thing that could cause problems is cloning params structure to shm and doing pointer translations relative to original buffer.
Cheers, Daniel
On Tue, Mar 2, 2010 at 3:20 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
On 03/02/2010 08:47 PM, Jan Janak wrote:
Module: sip-router Branch: master Commit: a3b2fcde99ebd5f625d0168473caef5dbbaf1029 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a3b2fcde...
Author: Jan Janakjan@ryngle.com Committer: Jan Janakjan@ryngle.com Date: Tue Feb 23 14:38:31 2010 -0500
param_parser: Accept parameters with missing bodies.
This change makes the parameter parser more forgiving. It accepts parameters with missing bodies (foo=), such parameters will have the body set to an empty string. Observed on iptel.org
is this better than setting the pointer after '=' and the len 0?
I haven't checked the code to see if it is the case, the only thing that could cause problems is cloning params structure to shm and doing pointer translations relative to original buffer.
You're right, I just checked the code and it could be a problem with record-route parameters, because there the pointers get translated.
I'll fix it, thanks for pointing this out!
-Jan