Explorar o código

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 %!s(int64=9) %!d(string=hai) anos
pai
achega
adbbe8b62d
Modificáronse 1 ficheiros con 6 adicións e 3 borrados
  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;