[sr-dev] git:master:a9972863: ctl: proper handling of optional param specifier (*) in rpc scan

Daniel-Constantin Mierla miconda at gmail.com
Tue Jan 23 17:35:02 CET 2018


Module: kamailio
Branch: master
Commit: a9972863681059c647af4bafd0d9a20f7648c801
URL: https://github.com/kamailio/kamailio/commit/a9972863681059c647af4bafd0d9a20f7648c801

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-01-23T17:33:39+01:00

ctl: proper handling of optional param specifier (*) in rpc scan

---

Modified: src/modules/ctl/binrpc_run.c

---

Diff:  https://github.com/kamailio/kamailio/commit/a9972863681059c647af4bafd0d9a20f7648c801.diff
Patch: https://github.com/kamailio/kamailio/commit/a9972863681059c647af4bafd0d9a20f7648c801.patch

---

diff --git a/src/modules/ctl/binrpc_run.c b/src/modules/ctl/binrpc_run.c
index 74d71dc8f9..efff292081 100644
--- a/src/modules/ctl/binrpc_run.c
+++ b/src/modules/ctl/binrpc_run.c
@@ -841,11 +841,11 @@ static int rpc_scan(struct binrpc_ctx* ctx, char* fmt, ...)
 	/* clear the previously saved error code */
 	rpc_fault_reset(ctx);
 
-	va_start(ap, fmt);
 	orig_fmt=fmt;
 	nofault = 0;
 	modifiers=0;
 	autoconv=autoconvert;
+	va_start(ap, fmt);
 	for (;*fmt; fmt++){
 		switch(*fmt){
 			case '*': /* start of optional parameters */
@@ -918,7 +918,7 @@ static int rpc_scan(struct binrpc_ctx* ctx, char* fmt, ...)
 error_read:
 	/* Do not immediately send out the error message, the user might retry the scan with
 	different parameters */
-	if(nofault==0 || ((err!=E_BINRPC_MORE_DATA) && (err!=E_BINRPC_EOP)))
+	if(nofault==0 || ((err!=E_BINRPC_MORE_DATA) && (err!=E_BINRPC_EOP))) {
 		rpc_fault_prepare(ctx, 400, "error at parameter %d: expected %s type but"
 						" %s", ctx->in.record_no, rpc_type_name(v.type),
 						 binrpc_error(err));
@@ -927,6 +927,11 @@ static int rpc_scan(struct binrpc_ctx* ctx, char* fmt, ...)
 						": %s", ctx->in.record_no, ctx->in.ctx.offset,
 								v.type, binrpc_error(err));
 	*/
+	}
+	if(nofault==1 && (err==E_BINRPC_MORE_DATA || err==E_BINRPC_EOP)) {
+		va_end(ap);
+		return (int)(fmt-orig_fmt)-modifiers;
+	}
 	goto error_ret;
 error_not_supported:
 	rpc_fault(ctx, 500, "internal server error, type %d not supported",




More information about the sr-dev mailing list