Prechádzať zdrojové kódy

usrloc: test first if all params are retrieved for rpc ul.add

- avoid logging unset values
Daniel-Constantin Mierla 8 rokov pred
rodič
commit
0954a069ac
1 zmenil súbory, kde vykonal 12 pridanie a 9 odobranie
  1. 12 9
      src/modules/usrloc/ul_rpc.c

+ 12 - 9
src/modules/usrloc/ul_rpc.c

@@ -579,19 +579,21 @@ static void ul_rpc_add(rpc_t* rpc, void* ctx)
 
 	ret = rpc->scan(ctx, "SSSdfSddd", &table, &aor, &contact, &ci.expires,
 			&dtemp, &path, &ci.flags, &ci.cflags, &ci.methods);
+	if ( ret != 9) {
+		rpc->fault(ctx, 500, "Not enough parameters or wrong format");
+		return;
+	}
 	if(path.len==1 && (strncmp(path.s, "0", 1)==0))	{
 		LM_DBG("path == 0 -> unset\n");
-	}
-	else {
+	} else {
 		ci.path = &path;
 	}
-	LM_DBG("ret: %d table:%.*s aor:%.*s contact:%.*s expires:%d dtemp:%f path:%.*s flags:%d bflags:%d methods:%d\n",
+	LM_DBG("ret: %d table:%.*s aor:%.*s contact:%.*s expires:%d"
+			" dtemp:%f path:%.*s flags:%d bflags:%d methods:%d\n",
 			ret, table.len, table.s, aor.len, aor.s, contact.len, contact.s,
-			(int) ci.expires, dtemp, (ci.path)?ci.path->len:0, (ci.path && ci.path->s)?ci.path->s:"", ci.flags, ci.cflags, (int) ci.methods);
-	if ( ret != 9) {
-		rpc->fault(ctx, 500, "Not enough parameters or wrong format");
-		return;
-	}
+			(int) ci.expires, dtemp, (ci.path)?ci.path->len:0,
+			(ci.path && ci.path->s)?ci.path->s:"", ci.flags, ci.cflags,
+			(int) ci.methods);
 	ci.q = double2q(dtemp);
 	temp.s = q2str(ci.q, (unsigned int*)&temp.len);
 	LM_DBG("q:%.*s\n", temp.len, temp.s);
@@ -627,7 +629,8 @@ static void ul_rpc_add(rpc_t* rpc, void* ctx)
 		}
 		c = 0;
 	} else {
-		if (get_ucontact( r, &contact, &rpc_ul_cid, &rpc_ul_path, RPC_UL_CSEQ+1, &c) < 0)
+		if (get_ucontact( r, &contact, &rpc_ul_cid, &rpc_ul_path,
+					RPC_UL_CSEQ+1, &c) < 0)
 		{
 			unlock_udomain( dom, &aor);
 			rpc->fault(ctx, 500, "Can't get record");