Module: sip-router
Branch: master
Commit: 3615f3c26405f1c1bcd3721674e9d87e4b589146
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3615f3c…
Author: Ovidiu Sas <osas(a)voipembedded.com>
Committer: Ovidiu Sas <osas(a)voipembedded.com>
Date: Thu Jan 16 18:02:31 2014 -0500
xhttp_rpc: fix arg parsing
---
modules/xhttp_rpc/xhttp_rpc_fnc.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/modules/xhttp_rpc/xhttp_rpc_fnc.c b/modules/xhttp_rpc/xhttp_rpc_fnc.c
index b25405e..5218c2f 100644
--- a/modules/xhttp_rpc/xhttp_rpc_fnc.c
+++ b/modules/xhttp_rpc/xhttp_rpc_fnc.c
@@ -310,7 +310,16 @@ void xhttp_rpc_get_next_arg(rpc_ctx_t* ctx, str *arg)
int i;
trim_leading(&ctx->arg2scan);
- if (ctx->arg2scan.len) {
+
+ if (ctx->arg2scan.len<=0) {
+ *arg = XHTTP_RPC_NULL_ARG;
+ return;
+ }
+ if (ctx->arg2scan.len==1 && ctx->arg2scan.s[0]=='\0') {
+ *arg = XHTTP_RPC_NULL_ARG;
+ return;
+ }
+ else {
*arg = ctx->arg2scan;
for(i=1; i<arg->len-1; i++) {
if(arg->s[i]==' '||arg->s[i]=='\t'||
@@ -322,8 +331,6 @@ void xhttp_rpc_get_next_arg(rpc_ctx_t* ctx, str *arg)
i++;
ctx->arg2scan.s += i;
ctx->arg2scan.len -= i;
- } else {
- *arg = XHTTP_RPC_NULL_ARG;
}
return;
}