Module: sip-router
Branch: sr_3.0
Commit: 9cb346dec84f191a53d1dbe5895f2e4276da67fe
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9cb346d…
Author: Jan Janak <jan(a)ryngle.com>
Committer: Jan Janak <jan(a)ryngle.com>
Date: Sun Oct 18 20:49:39 2009 +0200
event parser: Add missing string boundary checks to event_parser func.
The function event_parser needs to check that there is still some text
left in the input string before it attempts to read the text.
In addition to that the function also needs to skip any possible
leading whitespace before it calls parse_params, because parse_params
expects that there is no leading whitespace at the beginning of the
input string.
Reported by Juha Heinanen
---
parser/parse_event.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/parser/parse_event.c b/parser/parse_event.c
index 3d4b6b2..8adac43 100644
--- a/parser/parse_event.c
+++ b/parser/parse_event.c
@@ -117,10 +117,16 @@ int event_parser(char* s, int len, event_t* e)
tmp.s = end;
trim_leading(&tmp);
- if (tmp.s[0] == ';') {
+ e->params.list = NULL;
+
+ if (tmp.len && (tmp.s[0] == ';')) {
+ /* Shift the semicolon and skip any leading whitespace, this is needed
+ * for parse_params to work correctly. */
+ tmp.s++; tmp.len--;
+ trim_leading(&tmp);
+ if (!tmp.len) return 0;
+
/* We have parameters to parse */
- tmp.s++;
- tmp.len--;
if (e->type == EVENT_DIALOG) {
pclass = CLASS_EVENT_DIALOG;
phooks = (param_hooks_t*)&e->params.dialog;
@@ -130,10 +136,7 @@ int event_parser(char* s, int len, event_t* e)
ERR("event_parser: Error while parsing parameters parameters\n");
return -1;
}
- } else {
- e->params.list = NULL;
}
-
return 0;
}