소스 검색

usrloc: check on db delete the return value of memchr

When inserting into the database the AOR is split at the @ sign and
if there is no @ sign in the AOR only the domain part is filled and the
user part is left empty.

But for deleting this is not done and the query failed to be executed
and the AOR is not deleted. This PR add this behaviour of only comparing against the
domain part if the AOR doesn't contain a @ sign.
Rick Barenthin 1 년 전
부모
커밋
49276a1f43
1개의 변경된 파일9개의 추가작업 그리고 5개의 파일을 삭제
  1. 9 5
      src/modules/usrloc/urecord.c

+ 9 - 5
src/modules/usrloc/urecord.c

@@ -491,13 +491,17 @@ int db_delete_urecord(urecord_t *_r)
 	vals[0].val.str_val.len = _r->aor.len;
 
 	if(ul_use_domain) {
-		dom = memchr(_r->aor.s, '@', _r->aor.len);
-		vals[0].val.str_val.len = dom - _r->aor.s;
-
 		vals[1].type = DB1_STR;
 		vals[1].nul = 0;
-		vals[1].val.str_val.s = dom + 1;
-		vals[1].val.str_val.len = _r->aor.s + _r->aor.len - dom - 1;
+		dom = memchr(_r->aor.s, '@', _r->aor.len);
+		if(dom == 0) {
+			vals[0].val.str_val.len = 0;
+			vals[1].val.str_val = _r->aor;
+		} else {
+			vals[0].val.str_val.len = dom - _r->aor.s;
+			vals[1].val.str_val.s = dom + 1;
+			vals[1].val.str_val.len = _r->aor.s + _r->aor.len - dom - 1;
+		}
 	}
 
 	if(ul_dbf.use_table(ul_dbh, _r->domain) < 0) {