[sr-dev] git:4.1: xhttp_rpc: fix arg parsing

Ovidiu Sas osas at voipembedded.com
Fri Jan 17 00:05:34 CET 2014


Module: sip-router
Branch: 4.1
Commit: ab7f961dd22af7ce3cb451f30b116cc9a76bd4b5
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ab7f961dd22af7ce3cb451f30b116cc9a76bd4b5

Author: Ovidiu Sas <osas at voipembedded.com>
Committer: Ovidiu Sas <osas at voipembedded.com>
Date:   Thu Jan 16 18:02:31 2014 -0500

xhttp_rpc: fix arg parsing
(cherry picked from commit 3615f3c26405f1c1bcd3721674e9d87e4b589146)

---

 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;
 }




More information about the sr-dev mailing list