Explorar o código

dialog(k): reset default value for optional parameter

- some rpc transports set a static string for missing optional
  parameters, causing invalid value
- dlg.bridge_dlg proper handling of optional parameters return code
Daniel-Constantin Mierla %!s(int64=12) %!d(string=hai) anos
pai
achega
7fc74e46a5
Modificáronse 1 ficheiros con 16 adicións e 2 borrados
  1. 16 2
      modules_k/dialog/dialog.c

+ 16 - 2
modules_k/dialog/dialog.c

@@ -1626,7 +1626,11 @@ static void rpc_end_dlg_entry_id(rpc_t *rpc, void *c) {
 		rpc->fault(c, 500, "Invalid parameters");
 		return;
 	}
-	rpc->scan(c, "*S", &rpc_extra_hdrs);
+	if(rpc->scan(c, "*S", &rpc_extra_hdrs)<1)
+	{
+		rpc_extra_hdrs.s = NULL;
+		rpc_extra_hdrs.len = 0;
+	}
 
 	dlg = dlg_lookup(h_entry, h_id);
 	if(dlg==NULL) {
@@ -1665,8 +1669,18 @@ static void rpc_dlg_bridge(rpc_t *rpc, void *c) {
 	str from = {NULL,0};
 	str to = {NULL,0};
 	str op = {NULL,0};
+	int n;
 
-	if (rpc->scan(c, "SS*S", &from, &to, &op) < 2) return;
+	n = rpc->scan(c, "SS", &from, &to);
+	if (n< 2) {
+		LM_ERR("unable to read the parameters (%d)\n", n);
+		rpc->fault(c, 500, "Invalid parameters");
+		return;
+	}
+	if(rpc->scan(c, "*S", &op)<1) {
+		op.s = NULL;
+		op.len = 0;
+	}
 
 	dlg_bridge(&from, &to, &op);
 }