소스 검색

auth_db: use username when querying for credentials via is_subscriber

- for the case when credentials should not be stored, just discover if a
  record exists for the user
- avoids buffer overflow by setting all credentials columns, while
  trying to use only the first column
- reported by Anthony Messina, GH #500
Daniel-Constantin Mierla 9 년 전
부모
커밋
adbbe8b62d
1개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 6 3
      modules/auth_db/authorize.c

+ 6 - 3
modules/auth_db/authorize.c

@@ -62,13 +62,16 @@ int fetch_credentials(sip_msg_t *msg, str *user, str* domain, str *table, int fl
 		LM_ERR("no more pkg memory\n");
 		return -1;
 	}
-	col[0] = &user_column;
 
 	keys[0] = &user_column;
 	keys[1] = &domain_column;
 
-	for (n = 0, cred=credentials; cred ; n++, cred=cred->next) {
-		col[n] = &cred->text;
+	if(flags&AUTH_DB_SUBS_SKIP_CREDENTIALS) {
+		col[0] = &user_column;
+	} else {
+		for (n = 0, cred=credentials; cred ; n++, cred=cred->next) {
+			col[n] = &cred->text;
+		}
 	}
 
 	VAL_TYPE(vals) = VAL_TYPE(vals + 1) = DB1_STR;